fedora-accounts bz-make-components-pkgdb.py,1.2,1.3
Toshio Ernie Kuratomi (toshio)
fedora-extras-commits at redhat.com
Wed Aug 8 20:17:36 UTC 2007
- Previous message: rpms/initscripts/devel initscripts.spec,1.142,1.143
- Next message: rpms/kernel/devel linux-2.6-net-e1000e.patch, NONE, 1.1 config-generic, 1.13, 1.14 kernel.spec, 1.57, 1.58 linux-2.6-e1000-ich9.patch, 1.1, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: toshio
Update of /cvs/fedora/fedora-accounts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9486
Modified Files:
bz-make-components-pkgdb.py
Log Message:
Sync to a more recent version.
Index: bz-make-components-pkgdb.py
===================================================================
RCS file: /cvs/fedora/fedora-accounts/bz-make-components-pkgdb.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- bz-make-components-pkgdb.py 2 Jul 2007 17:17:50 -0000 1.2
+++ bz-make-components-pkgdb.py 8 Aug 2007 20:17:33 -0000 1.3
@@ -1,21 +1,25 @@
#!/usr/bin/python -t
-
+# -*- coding: utf-8 -*-
import sys, os, errno
import website, crypt
import getopt, re
import xmlrpclib
import json
import urllib2
+import codecs
+import locale
from fedora.accounts.fas import AccountSystem
# Set this to the production bugzilla account when we're ready to go live
BZSERVER = 'https://bugdev.devel.redhat.com/bugzilla-cvs/xmlrpc.cgi'
#BZSERVER = 'https://bugzilla.redhat.com/bugzilla/xmlrpc.cgi'
-BZUSER='toshio at tiki-lounge.com'
-BZPASS='tanuki7'
+BZDBHOST='bugdev'
+#BZDBHOST='bugs'
+BZUSER=''
+BZPASS=''
-PKGDBSERVER = 'http://test3.fedora.phx.redhat.com/pkgdb-dev/acls/bugzilla?tg_format=json'
+PKGDBSERVER = 'https://admin.fedoraproject.org/pkgdb/acls/bugzilla/?tg_format=json'
# Set this to False when we're ready to run it against the bz database
DRY_RUN = True
@@ -31,6 +35,8 @@
def __init__(self, bzServer, username, password):
self.userCache = {}
+ self.userCache['extras-qa at fedoraproject.org'] = {}
+ self.userCache['extras-qa at fedoraproject.org']['email'] = 'extras-qa at fedoraproject.org'
self.productCache = {}
self.bzXmlRpcServer = bzServer
self.username = username
@@ -39,17 +45,20 @@
self.server = xmlrpclib.Server(bzServer)
# We still have to talk directly to the db for some things
- self.bzdbh = website.get_dbh('bugs', 'bugs')
+ self.bzdbh = website.get_dbh('bugs', BZDBHOST)
self.bzdbc = self.bzdbh.cursor()
self.bzdbh.commit()
+ # Connect to the fedora account system
+ self.fas = AccountSystem()
+
def _get_bugzilla_email(self, username):
try:
user = self.userCache[username]
except KeyError:
user = {}
(person, groups) = self.fas.get_user_info(username)
- user['email'] = person['bugzilla_email']
+ user['email'] = person['bugzilla_email'].lower()
self.userCache[username] = user
return user['email']
@@ -61,7 +70,7 @@
except fas.AuthError, e:
raise ValueError, 'Username %s was not found in fas' % username
- email = person['bugzilla_email']
+ email = person['bugzilla_email'].lower()
user['email'] = email
return email
@@ -73,7 +82,7 @@
except KeyError:
self._get_bugzilla_email(username)
user = self.userCache[username]
-
+
try:
bzid = user['bzid']
except KeyError:
@@ -100,50 +109,72 @@
components = self.server.bugzilla.getProdCompDetails(collection,
self.username, self.password)
- # This ugly construction changes from the form:
+ # This changes from the form:
# {'component': 'PackageName',
# 'initialowner': 'OwnerEmail',
# 'initialqacontact': 'QAContactEmail',
# 'description': 'One sentence summary'}
# to:
- # product['PackageName'] = {'initialowner': 'OwnerEmail',
+ # product['packagename'] = {'component': 'PackageName',
+ # 'initialowner': 'OwnerEmail',
# 'initialqacontact': 'QAContactEmail',
# 'description': 'One sentenct summary'}
- for record in map(lambda x: (x['component'], [z for z in x.items() if lambda y: y[0] != 'component']), components):
- product[record[0]] = {}
- product[record[0]].update(record[1])
+ # This allows us to check in a case insensitive manner for the
+ # package.
+ for record in components:
+ record['component'] = unicode(record['component'], 'utf-8')
+ try:
+ record['description'] = unicode(record['description'], 'utf-8')
+ except TypeError:
+ try:
+ record['description'] = unicode(record['description'].data, 'utf-8')
+ except:
+ record['description'] = None
+ product[record['component'].lower()] = record
self.productCache[collection] = product
- if package in product:
+ pkgKey = package.lower()
+ if pkgKey in product:
# edit the package information
data = {}
# Grab bugzilla email for things changable via xmlrpc
- owner = self._get_bugzilla_email(owner)
+ owner = self._get_bugzilla_email(owner).lower()
if qacontact:
qacontact = self._get_bugzilla_email(qacontact)
+ else:
+ qacontact = 'extras-qa at fedoraproject.org'
# Check for changes to the owner, qacontact, or description
- if product[package]['initialowner'] != owner:
+ if product[pkgKey]['initialowner'] != owner:
data['initialowner'] = owner
- if product[package]['description'] == description:
+
+ if product[pkgKey]['description'] != description:
data['description'] = description
- if product[package]['initialqacontact'] != qacontact and (
- qacontact or product[package]['initialqacontact']):
+ if product[pkgKey]['initialqacontact'] != qacontact and (
+ qacontact or product[pkgKey]['initialqacontact']):
data['initialqacontact'] = qacontact
if data:
# Changes occurred. Submit a request to change via xmlrpc
data['product'] = collection
- data['component'] = package
+ data['component'] = product[pkgKey]['component']
if DRY_RUN:
- print 'Changing via editComponent(%s, %s, "xxxxx")' % (
+ print '[EDITCOMP] Changing via editComponent(%s, %s, "xxxxx")' % (
data, self.username)
+ print '[EDITCMP] Former values: %s|%s|%s' % (
+ product[pkgKey]['initialowner'],
+ product[pkgKey]['description'],
+ product[pkgKey]['initialqacontact'])
else:
- self.server.bugzilla.editComponent(data, self.username,
- self.password)
-
+ try:
+ self.server.bugzilla.editComponent(data, self.username,
+ self.password)
+ except xmlrpclib.Fault, e:
+ # Output something useful in args
+ e.args = (faultCode, faultString)
+ raise
### FIXME: Check for changes to cclist
# We're going to wait on the xmlrpc interface returning cclist
@@ -160,52 +191,58 @@
# Turn all cclist members into bugzilla ids
bzCclist = []
- for watcher in cclist:
+ for watcher in cclist['people']:
bzCclist.append(self._get_bugzilla_user_id(watcher))
+ ### FIXME: In the future, handle groups as well
+
# Update the cclist in the database
if DRY_RUN:
- print "update components set initialcclist = '%s'" \
- " where id = '%s'" % (':'.join(map(str,bzCclist)),
+ print "[CCLIST] update components set initialcclist = '%s'" \
+ " where id = '%s'" % (':'.join(map(str, bzCclist)),
pkgId)
-
else:
self.bzdbc.execute("update components set initialcclist = %s" \
- " where id = %s", (':'.join(map(str,bzCclist)), pkgId))
+ " where id = %s", (':'.join(map(str, bzCclist)), pkgId))
self.bzdbh.commit()
else:
# Add component
# Get the product id
- self.bzdbc.execute("select id from products where name = %s", collection)
+ self.bzdbc.execute("select id from products where name = %s", (collection,))
if not self.bzdbc.rowcount:
raise DataChangedError, 'Collection %s disappeared from the database during processing' % (collection,)
collectionId = self.bzdbc.fetchone()[0]
# Retrieve bugzilla ids for all the fas usernames
ownerId = self._get_bugzilla_user_id(owner)
- qacontactId = self._get_bugzilla_user_id(qacontact)
+ if qacontact:
+ qacontactId = self._get_bugzilla_user_id(qacontact)
+ else:
+ qacontactId = self._get_bugzilla_user_id('extras-qa at fedoraproject.org')
bzCclist = []
- for watcher in cclist:
+ for watcher in cclist['people']:
bzCclist.append(self._get_bugzilla_user_id(watcher))
+ ### FIXME: Handle groups as well.
# Add the component
if DRY_RUN:
- print "insert into components (name, product_id, description," \
+ print "[ADDCOMP] insert into components (name, product_id, description," \
" initialowner, initialqacontact, initialcclist)" \
" values (%s, %s, %s, %s, %s, %s)" % (package,
collectionId, description, ownerId,
- qacontactId, bzCclist)
+ qacontactId, ':'.join(map(str, bzCclist)))
else:
self.bzdbc.execute("insert into components" \
" (name, product_id, description," \
" initialowner, initialqacontact, initialcclist)" \
- " values (%s, %s, %s, %s, %s, %s)" % (package,
+ " values (%s, %s, %s, %s, %s, %s)", (package,
collectionId, description, ownerId,
- qacontactId, bzCclist))
+ qacontactId, ':'.join(map(str, bzCclist))))
self.bzdbh.commit()
-
if __name__ == '__main__':
+ sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
+
opts, args = getopt.getopt(sys.argv[1:], '', ('usage', 'help'))
if len(args) > 0:
print """
@@ -229,49 +266,38 @@
del bugzillaData
for product in acls.keys():
+ if product not in ('Fedora', 'Fedora OLPC', 'Fedora EPEL'):
+ continue
+ output = file('outfile', 'w')
for pkg in acls[product]:
pkgInfo = acls[product][pkg]
- ### FIXME:
- # Catch the exceptions and save information into email to send
- print 'here we are'
- print 'pkg:%s' % pkg
- print 'product:%s' % product
- print 'pkgInfo.owner:%s' % pkgInfo['owner']
- print 'pkgInfo.summary:%s' % pkgInfo['summary']
- print 'pkgInfo.qacontact:%s' % pkgInfo['qacontact']
- print 'pkgInfo.cclist:%s' % pkgInfo['cclist']
- sys.exit(1)
try:
- bugzilla.add_edit_component(pkg, product, pkgInfo['owner'],
- pkgInfo['summary'], pkgInfo['qacontact'],
- pkgInfo['cclist'])
+ bugzilla.add_edit_component(pkg, product,
+ pkgInfo['owner'], pkgInfo['summary'],
+ pkgInfo['qacontact'], pkgInfo['cclist'])
except ValueError, e:
# A username didn't have a bugzilla address
- errors.append(e)
+ errors.append(str(e.args))
except DataChangedError, e:
# A Package or Collection was returned via xmlrpc but wasn't
# present when we tried to change it
- errors.append(e)
+ errors.append(str(e.args))
except xmlrpclib.Error, e:
# An error occurred in the xmlrpc call. Shouldn't happen but
# we better se what it is
- errors.append(e)
-
-# Send notification of errors
+ errors.append(str(e.args))
+ # Send notification of errors
if errors:
+ print '[DEBUG]', '\n'.join(errors)
website.send_email('accounts at fedoraproject.org',
'toshio at fedoraproject.org',
'Errors while syncing bugzilla with the PackageDB',
'''
-In order to make bugzilla components for Fedora-related programs, we need to have an existing bugzilla account for
-the listed owner. You (%s) do not have a bugzilla account, but are listed as the owner for the following components:
-%s
+The following errors were encountered while updating bugzilla with information
+from the Package Database. Please have the problems taken care of:
-Please create a bugzilla account for %s immediately, because this amazingly stupid cron job will keep sending you an
-e-mail every hour until you do :)
-
-- The management
-''' % ('\n'.join(str(errors)),))
+%s
+''' % ('\n'.join(errors),))
sys.exit(0)
- Previous message: rpms/initscripts/devel initscripts.spec,1.142,1.143
- Next message: rpms/kernel/devel linux-2.6-net-e1000e.patch, NONE, 1.1 config-generic, 1.13, 1.14 kernel.spec, 1.57, 1.58 linux-2.6-e1000-ich9.patch, 1.1, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the scm-commits
mailing list