| |
@@ -14,7 +14,7 @@
|
| |
from genshi.template import TemplateLoader
|
| |
from optparse import OptionParser
|
| |
from validate import Validator
|
| |
-
|
| |
+ from fedora.client.fas2 import AccountSystem
|
| |
VERSION = "4.1"
|
| |
|
| |
# Red Hat's bugzilla
|
| |
@@ -39,6 +39,10 @@
|
| |
# So the bugzilla module has some way to complain
|
| |
logging.basicConfig()
|
| |
|
| |
+ fasusernamemap = {}
|
| |
+ isnewpackager = {}
|
| |
+ nonefasinfo = {}
|
| |
+ approvedpackagers = {}
|
| |
|
| |
def parse_commandline():
|
| |
usage = "usage: %prog [options] -c <bugzilla_config> -d <dest_dir> -t <template_dir>"
|
| |
@@ -76,6 +80,8 @@
|
| |
url = string(default='https://bugzilla.redhat.com/xmlrpc.cgi')
|
| |
username = string()
|
| |
password = string()
|
| |
+ adminfasusername = string()
|
| |
+ adminfaspassword = string()
|
| |
'''.splitlines()
|
| |
|
| |
cfg = ConfigObj(file, configspec=spec)
|
| |
@@ -177,7 +183,7 @@
|
| |
'alias', 'assigned_to', 'product', 'creator', 'creator_id', 'status', 'resolution',
|
| |
'component', 'blocks', 'depends_on', 'summary',
|
| |
'whiteboard', 'flags']
|
| |
- querydata['bug_status'] = ['NEW', 'ASSIGNED', 'MODIFIED']
|
| |
+ querydata['bug_status'] = ['NEW', 'ASSIGNED', 'MODIFIED','POST']
|
| |
querydata['product'] = ['Fedora', 'Fedora EPEL']
|
| |
querydata['component'] = ['Package Review']
|
| |
querydata['query_format'] = 'advanced'
|
| |
@@ -190,6 +196,7 @@
|
| |
dbprint("Running main query.")
|
| |
t = time.time()
|
| |
bugs = filter(lambda b: b.id not in trackers, bz.query(querydata))
|
| |
+ bugs = bugs[200:500]
|
| |
dbprint("Done, took {0:.2f}.".format(time.time() - t))
|
| |
|
| |
for bug in bugs:
|
| |
@@ -337,6 +344,49 @@
|
| |
return 1
|
| |
return 0
|
| |
|
| |
+ def get_fas_username(bug):
|
| |
+ ''' find the fas name of package submiter based on first few comments'''
|
| |
+ comments = bug.getcomments()
|
| |
+ # some review ticket have an empty first comment(ex.1282012)
|
| |
+ for comment in comments:
|
| |
+ username_idx = comment['text'].find('sername')
|
| |
+ if username_idx != -1:
|
| |
+ fas_username = comment['text'][username_idx:]
|
| |
+ break
|
| |
+ try:
|
| |
+ fas_username = fas_username[fas_username.find(':')+1:]
|
| |
+ if fas_username[0] == '\n':
|
| |
+ fas_username = fas_username[1:][:fas_username.find('\n')]
|
| |
+ def stripe_spaces(fas_username):
|
| |
+ if fas_username[0] == ' ':
|
| |
+ return fas_username[1:]
|
| |
+ stripe_spaces(fas_username)
|
| |
+ else:
|
| |
+ return fas_username
|
| |
+ except UnboundLocalError:
|
| |
+ dbprint(comment)
|
| |
+ return ''
|
| |
+ #most have space before fas username, but some don't.(ex.879752)
|
| |
+
|
| |
+
|
| |
+
|
| |
+ def is_new_packager(bug):
|
| |
+ #global variable used: isnewpackager,fasusernamemap,nonefasinfo
|
| |
+ try:
|
| |
+ return isnewpackager[bug.reporter]
|
| |
+ except KeyError :
|
| |
+ fasusername = get_fas_username(bug)
|
| |
+ if fasusername == '' :
|
| |
+ try:
|
| |
+ nonefasinfo[bug.reporter].append(bug)
|
| |
+ except KeyError :
|
| |
+ nonefasinfo[bug.reporter] = [bug]
|
| |
+ return False
|
| |
+ else:
|
| |
+ fasusernamemap[bug.reporter] = fasusername
|
| |
+ isnewpackager[bug.reporter] = not (fasusername in approvedpackagers)
|
| |
+ return not (fasusername in approvedpackagers)
|
| |
+
|
| |
|
| |
def select_needsponsor(bug, bugd):
|
| |
wb = string.lower(bug.whiteboard)
|
| |
@@ -345,11 +395,12 @@
|
| |
and NEEDSPONSOR in bugd['blocks']
|
| |
and LEGAL not in bugd['blocks']
|
| |
and bug.bug_status != 'CLOSED'
|
| |
- and nobody(bug.assigned_to) == '(Nobody)'
|
| |
and wb.find('buildfails') < 0
|
| |
and wb.find('notready') < 0
|
| |
and wb.find('stalledsubmitter') < 0
|
| |
- and wb.find('awaitingsubmitter') < 0):
|
| |
+ and wb.find('awaitingsubmitter') < 0
|
| |
+ and (nobody(bug.assigned_to) == '(Nobody)'
|
| |
+ or is_new_packager(bug))):
|
| |
return 1
|
| |
return 0
|
| |
|
| |
@@ -411,6 +462,14 @@
|
| |
rowclass = 'bz_row_even'
|
| |
return rowclass
|
| |
|
| |
+ def rowclass_accepted_packages(bug, count):
|
| |
+ rowclass = 'bz_row_odd'
|
| |
+ if (bug.bug_status in ['ASSIGNED','POST']
|
| |
+ or nobody(bug.assigned_to) != '(Nobody)'):
|
| |
+ rowclass = 'bz_state_NEEDSPONSOR'
|
| |
+ elif count % 2 == 1:
|
| |
+ rowclass = 'bz_row_even'
|
| |
+ return rowclass
|
| |
|
| |
# The data from a standard row in a bug list
|
| |
def std_row(bug, rowclass):
|
| |
@@ -516,7 +575,8 @@
|
| |
|
| |
def report_needsponsor(bugs, bugdata, loader, usermap, tmpdir, subs):
|
| |
data = deepcopy(subs)
|
| |
- data['description'] = 'This page lists all new NEEDSPONSOR tickets (those without the fedora-review flag set).'
|
| |
+ data['description'] = ('This page lists new NEEDSPONSOR tickets submitted by new packagers who are not yet sponsored.'
|
| |
+ 'Tickets colored green are already being assigned for review.')
|
| |
data['title'] = 'NEEDSPONSOR tickets'
|
| |
curreporter = ''
|
| |
curcount = 0
|
| |
@@ -526,7 +586,14 @@
|
| |
for i in bugs:
|
| |
if select_needsponsor(i, bugdata[i.id]):
|
| |
selected.append(i)
|
| |
-
|
| |
+ #cleanup bugs that have no fas username
|
| |
+ for i in nonefasinfo:
|
| |
+ try:
|
| |
+ if isnewpackager[i]:
|
| |
+ selected += nonefasinfo[i]
|
| |
+ except KeyError :
|
| |
+ pass
|
| |
+
|
| |
# Determine the oldest reported bug
|
| |
for i in selected:
|
| |
if i.reporter not in oldest:
|
| |
@@ -538,7 +605,6 @@
|
| |
selected.sort(key=lambda a: oldest[a.reporter])
|
| |
|
| |
for i in selected:
|
| |
- rowclass = rowclass_plain(data['count'])
|
| |
r = i.reporter
|
| |
|
| |
if curreporter != r:
|
| |
@@ -549,7 +615,7 @@
|
| |
data['packagers'].append({'email': r, 'name': name, 'oldest': human_date(oldest[r]), 'bugs': []})
|
| |
curreporter = r
|
| |
curcount = 0
|
| |
-
|
| |
+ rowclass = rowclass_accepted_packages(i, curcount)
|
| |
data['packagers'][-1]['bugs'].append(std_row(i, rowclass))
|
| |
data['count'] += 1
|
| |
curcount += 1
|
| |
@@ -630,6 +696,9 @@
|
| |
bz = bugzilla.RHBugzilla(url=config['url'], cookiefile=None, user=config['username'], password=config['password'])
|
| |
t = time.time()
|
| |
(bugs, bugdata, usermap) = run_query(bz)
|
| |
+ approvedpackagers=[]
|
| |
+ for indi in AccountSystem(username=config['adminfasusername'],password=config['adminfaspassword']).group_members('packager'):
|
| |
+ approvedpackagers.append(indi.toDict()['username'].encode('utf-8'))
|
| |
querytime = time.time() - t
|
| |
|
| |
# Don't bother running this stuff until the query completes, since it fails
|
| |