3
# Copyright 2009 Canonical Ltd. This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
11
from zope.component import getUtility
13
from canonical.lp import initZopeless
14
from canonical.launchpad.scripts import execute_zcml_for_scripts
15
from canonical.launchpad.interfaces.emailaddress import IEmailAddressSet
16
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
17
from lp.app.errors import NotFoundError
18
from lp.registry.interfaces.person import IPersonSet
21
execute_zcml_for_scripts()
23
logging.basicConfig(level=logging.INFO)
25
ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
26
techboard = getUtility(IPersonSet).getByName('techboard')
28
def getPerson(email, realname):
29
# The debzilla user acts as a placeholder for "no specific maintainer".
30
# We don't create a bug contact record for it.
31
if email is None or email == 'debzilla@ubuntu.com':
34
personset = getUtility(IPersonSet)
35
person = personset.getByEmail(email)
39
# we mark the bugzilla email as preferred email, since it has been
41
if email.endswith('@lists.ubuntu.com'):
42
logging.info('creating team for %s (%s)', email, realname)
43
person = personset.newTeam(techboard, email[:-17], realname)
44
email = getUtility(IEmailAddressSet).new(email, person.id)
45
person.setPreferredEmail(email)
47
logging.info('creating person for %s (%s)', email, realname)
48
person, email = personset.createPersonAndEmail(email,
50
person.setPreferredEmail(email)
55
conn = MySQLdb.connect(db='bugs_warty')
56
cursor = conn.cursor()
58
# big arse query that gets all the default assignees and QA contacts:
60
"SELECT components.name, owner.login_name, owner.realname, "
61
" qa.login_name, qa.realname "
63
" JOIN products ON components.product_id = products.id "
64
" LEFT JOIN profiles AS owner ON components.initialowner = owner.userid"
65
" LEFT JOIN profiles AS qa ON components.initialqacontact = qa.userid "
66
" WHERE products.name = 'Ubuntu'")
68
for (component, owneremail, ownername, qaemail, qaname) in cursor.fetchall():
69
logging.info('Processing %s', component)
71
srcpkgname, binpkgname = ubuntu.getPackageNames(component)
72
except NotFoundError, e:
73
logging.warning('could not find package name for "%s": %s', component,
77
srcpkg = ubuntu.getSourcePackage(srcpkgname)
79
# default assignee => maintainer
80
person = getPerson(owneremail, ownername)
82
if not srcpkg.isBugContact(person):
83
srcpkg.addBugContact(person)
85
# QA contact => maintainer
86
person = getPerson(qaemail, qaname)
88
if not srcpkg.isBugContact(person):
89
srcpkg.addBugContact(person)