Update for new python-bugzilla.
This commit is contained in:
parent
26f7b778a1
commit
41555091d1
1 changed files with 33 additions and 31 deletions
|
@ -23,6 +23,7 @@ import codecs
|
||||||
import datetime
|
import datetime
|
||||||
import getpass
|
import getpass
|
||||||
import glob
|
import glob
|
||||||
|
import logging
|
||||||
import operator
|
import operator
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -54,6 +55,8 @@ epel_ok_comaint = ['alexlan', 'guidograzioli', 'jwrdegoede', 'kkofler',
|
||||||
PAGER = os.environ.get('PAGER') or '/usr/bin/less'
|
PAGER = os.environ.get('PAGER') or '/usr/bin/less'
|
||||||
EDITOR = os.environ.get('EDITOR') or '/bin/vi'
|
EDITOR = os.environ.get('EDITOR') or '/bin/vi'
|
||||||
|
|
||||||
|
logging.basicConfig()
|
||||||
|
|
||||||
# Override a method in xmlrpclib so it doesn't blow up when getting crap data
|
# Override a method in xmlrpclib so it doesn't blow up when getting crap data
|
||||||
# from Red Hat's bugzilla.
|
# from Red Hat's bugzilla.
|
||||||
# Bugfixes seem to have rendered this unnecessary
|
# Bugfixes seem to have rendered this unnecessary
|
||||||
|
@ -169,19 +172,21 @@ def edit_package(pkgdb, request):
|
||||||
|
|
||||||
def run_query(bz):
|
def run_query(bz):
|
||||||
querydata = {}
|
querydata = {}
|
||||||
querydata['column_list'] = ['opendate', 'changeddate', 'bug_severity',
|
querydata['column_list'] = ['id', 'creation_time',
|
||||||
'alias', 'assigned_to', 'reporter', 'bug_status', 'resolution',
|
'assigned_to', 'reporter', 'bug_status', 'resolution',
|
||||||
'component', 'blockedby', 'dependson', 'short_desc',
|
'component', 'blockedby', 'dependson', 'summary',
|
||||||
'status_whiteboard', 'flagtypes.name']
|
'status_whiteboard', 'flags']
|
||||||
|
|
||||||
querydata['field0-0-0'] = 'flagtypes.name'
|
querydata['query_format'] = 'advanced'
|
||||||
querydata['type0-0-0'] = 'equals'
|
querydata['product'] = ['Fedora', 'Fedora EPEL']
|
||||||
querydata['value0-0-0'] = 'fedora-cvs?'
|
querydata['f1'] = 'flagtypes.name'
|
||||||
|
querydata['o1'] = 'equals'
|
||||||
|
querydata['v1'] = 'fedora-cvs?'
|
||||||
|
|
||||||
bugs = bz.query(querydata)
|
bugs = bz.query(querydata)
|
||||||
bugs.sort(key=operator.attrgetter('bug_id'))
|
bugs.sort(key=operator.attrgetter('id'))
|
||||||
|
|
||||||
ids = map(lambda x: x.bug_id, bugs)
|
ids = map(lambda x: x.id, bugs)
|
||||||
comments = bz._proxy.Bug.comments({"ids": ids})
|
comments = bz._proxy.Bug.comments({"ids": ids})
|
||||||
|
|
||||||
return [bugs, comments]
|
return [bugs, comments]
|
||||||
|
@ -190,9 +195,9 @@ def display_bug(bug, comments):
|
||||||
'''Show the complete ticket in a pager.'''
|
'''Show the complete ticket in a pager.'''
|
||||||
comment = 0
|
comment = 0
|
||||||
b = []
|
b = []
|
||||||
b.append('https://bugzilla.redhat.com/%d' % bug.bug_id)
|
b.append('https://bugzilla.redhat.com/%d' % bug.id)
|
||||||
b.append('Bug %d - %s' % (bug.bug_id, bug.short_desc))
|
b.append('Bug %d - %s' % (bug.id, bug.summary))
|
||||||
b.append('Reported by: %s at %s' % (bug.reporter, bug.opendate))
|
b.append('Reported by: %s at %s' % (bug.reporter, bug.creation_time))
|
||||||
b.append('Assigned to: %s' % (bug.assigned_to))
|
b.append('Assigned to: %s' % (bug.assigned_to))
|
||||||
for i in comments:
|
for i in comments:
|
||||||
b.append('-'*40)
|
b.append('-'*40)
|
||||||
|
@ -326,8 +331,8 @@ def clean_request(items):
|
||||||
|
|
||||||
def new_request_string(items, bug):
|
def new_request_string(items, bug):
|
||||||
r = []
|
r = []
|
||||||
r.append("Bug URL: http://bugzilla.redhat.com/%d " % bug.bug_id)
|
r.append("Bug URL: http://bugzilla.redhat.com/%d " % bug.id)
|
||||||
r.append("Bug summary: " + bug.short_desc)
|
r.append("Bug summary: " + bug.summary)
|
||||||
r.append('')
|
r.append('')
|
||||||
r.append("New Package SCM Request")
|
r.append("New Package SCM Request")
|
||||||
r.append("=======================")
|
r.append("=======================")
|
||||||
|
@ -341,8 +346,8 @@ def new_request_string(items, bug):
|
||||||
|
|
||||||
def change_request_string(items, bug):
|
def change_request_string(items, bug):
|
||||||
r = []
|
r = []
|
||||||
r.append("Bug URL: http://bugzilla.redhat.com/%d" % bug.bug_id)
|
r.append("Bug URL: http://bugzilla.redhat.com/%d" % bug.id)
|
||||||
r.append("Bug summary: " + bug.short_desc)
|
r.append("Bug summary: " + bug.summary)
|
||||||
r.append('')
|
r.append('')
|
||||||
r.append("Package Change Request")
|
r.append("Package Change Request")
|
||||||
r.append("======================")
|
r.append("======================")
|
||||||
|
@ -387,7 +392,7 @@ def process_no_request(bug, allcomments):
|
||||||
'''Deal with a ticket where no request was found.'''
|
'''Deal with a ticket where no request was found.'''
|
||||||
while 1:
|
while 1:
|
||||||
clear()
|
clear()
|
||||||
print "No SCM request found in bug %d\nhttp://bugzilla.redhat.com/%d." % (bug.bug_id, bug.bug_id)
|
print "No SCM request found in bug %d\nhttp://bugzilla.redhat.com/%d." % (bug.id, bug.id)
|
||||||
ok = raw_input('\nWhat do? (n=Next, s=Show ticket, b=Show ticket in browser, c=Comment, q=Quit):')
|
ok = raw_input('\nWhat do? (n=Next, s=Show ticket, b=Show ticket in browser, c=Comment, q=Quit):')
|
||||||
if ok == 'c':
|
if ok == 'c':
|
||||||
bug_comment = edit_string('')
|
bug_comment = edit_string('')
|
||||||
|
@ -409,7 +414,7 @@ def process_no_request(bug, allcomments):
|
||||||
print
|
print
|
||||||
display_bug(bug, allcomments)
|
display_bug(bug, allcomments)
|
||||||
elif ok == 'b':
|
elif ok == 'b':
|
||||||
webbrowser.open("http://bugzilla.redhat.com/" + str(bug.bug_id), new=1)
|
webbrowser.open("http://bugzilla.redhat.com/" + str(bug.id), new=1)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_owners(fas, owner, comaintainers, cc_list):
|
def check_owners(fas, owner, comaintainers, cc_list):
|
||||||
|
@ -478,14 +483,11 @@ def process_new_request(bug, comment, allcomments, firstfound, pkgdb, fas, branc
|
||||||
warnings.append("WARNING: Ticket is not assigned to anyone.")
|
warnings.append("WARNING: Ticket is not assigned to anyone.")
|
||||||
warned = True
|
warned = True
|
||||||
|
|
||||||
# This is an unpleasant hack
|
if bug.flags.find('fedora-review+') < 0:
|
||||||
flags = bug.__getattr__('flagtypes.name')
|
|
||||||
if flags.find('fedora-review+') < 0:
|
|
||||||
warnings.append("WARNING: fedora-review flag not set to '+'")
|
warnings.append("WARNING: fedora-review flag not set to '+'")
|
||||||
warned = True
|
warned = True
|
||||||
|
|
||||||
short_desc = bug.short_desc
|
m=re.search('Review Request:\s+([a-zA-Z0-9_+.-]+)\s+', bug.summary, re.I)
|
||||||
m=re.search('Review Request:\s+([a-zA-Z0-9_+.-]+)\s+', short_desc, re.I)
|
|
||||||
if not m:
|
if not m:
|
||||||
warnings.append("WARNING: Couldn't parse package name out of bug summary.")
|
warnings.append("WARNING: Couldn't parse package name out of bug summary.")
|
||||||
warned = True
|
warned = True
|
||||||
|
@ -541,7 +543,7 @@ def process_new_request(bug, comment, allcomments, firstfound, pkgdb, fas, branc
|
||||||
print
|
print
|
||||||
display_bug(bug, allcomments)
|
display_bug(bug, allcomments)
|
||||||
elif ok == 'b':
|
elif ok == 'b':
|
||||||
webbrowser.open("http://bugzilla.redhat.com/" + str(bug.bug_id), new=1)
|
webbrowser.open("http://bugzilla.redhat.com/" + str(bug.id), new=1)
|
||||||
elif ok == 'yes' and not warned:
|
elif ok == 'yes' and not warned:
|
||||||
bug_comment = edit_string(bug_comment)
|
bug_comment = edit_string(bug_comment)
|
||||||
print '\n', bug_comment
|
print '\n', bug_comment
|
||||||
|
@ -615,7 +617,6 @@ def process_change_request(bug, comment, allcomments, firstfound, pkgdb, branche
|
||||||
warnings.append("WARNING: Invalid branch %s requested" % i)
|
warnings.append("WARNING: Invalid branch %s requested" % i)
|
||||||
warned = True
|
warned = True
|
||||||
|
|
||||||
short_desc = bug.short_desc
|
|
||||||
req_string = change_request_string(items, bug)
|
req_string = change_request_string(items, bug)
|
||||||
bug_comment = 'Git done (by process-git-requests).\n'
|
bug_comment = 'Git done (by process-git-requests).\n'
|
||||||
|
|
||||||
|
@ -663,7 +664,7 @@ def process_change_request(bug, comment, allcomments, firstfound, pkgdb, branche
|
||||||
print
|
print
|
||||||
display_bug(bug, allcomments)
|
display_bug(bug, allcomments)
|
||||||
elif ok == 'b':
|
elif ok == 'b':
|
||||||
webbrowser.open("http://bugzilla.redhat.com/" + str(bug.bug_id), new=1)
|
webbrowser.open("http://bugzilla.redhat.com/" + str(bug.id), new=1)
|
||||||
elif ok == 'yes' and not warned:
|
elif ok == 'yes' and not warned:
|
||||||
bug_comment = edit_string(bug_comment)
|
bug_comment = edit_string(bug_comment)
|
||||||
print '\n', bug_comment
|
print '\n', bug_comment
|
||||||
|
@ -703,6 +704,7 @@ if __name__ == '__main__':
|
||||||
branches = {}
|
branches = {}
|
||||||
processed = []
|
processed = []
|
||||||
options = parse_commandline()
|
options = parse_commandline()
|
||||||
|
|
||||||
print "Connecting to bugzilla..."
|
print "Connecting to bugzilla..."
|
||||||
bz = bugzilla.Bugzilla(url=options.url)
|
bz = bugzilla.Bugzilla(url=options.url)
|
||||||
print "Querying bugzilla..."
|
print "Querying bugzilla..."
|
||||||
|
@ -743,8 +745,8 @@ if __name__ == '__main__':
|
||||||
for i in bugs:
|
for i in bugs:
|
||||||
firstfound = True
|
firstfound = True
|
||||||
type = ''
|
type = ''
|
||||||
print "Parsing bug %d - https://bugzilla.redhat.com/%d" % (i.bug_id, i.bug_id)
|
print "Parsing bug %d - https://bugzilla.redhat.com/%d" % (i.id, i.id)
|
||||||
for j in reversed(comments['bugs'][str(i.bug_id)]['comments']):
|
for j in reversed(comments['bugs'][str(i.id)]['comments']):
|
||||||
if newre.search(j['text']):
|
if newre.search(j['text']):
|
||||||
type = 'new'
|
type = 'new'
|
||||||
break
|
break
|
||||||
|
@ -753,11 +755,11 @@ if __name__ == '__main__':
|
||||||
break
|
break
|
||||||
firstfound = False
|
firstfound = False
|
||||||
else:
|
else:
|
||||||
if not process_no_request(i, comments['bugs'][str(i.bug_id)]['comments']):
|
if not process_no_request(i, comments['bugs'][str(i.id)]['comments']):
|
||||||
break
|
break
|
||||||
|
|
||||||
if type == 'new':
|
if type == 'new':
|
||||||
(package, more) = process_new_request(i, j, comments['bugs'][str(i.bug_id)]['comments'], firstfound, pkgdb, fas, branches)
|
(package, more) = process_new_request(i, j, comments['bugs'][str(i.id)]['comments'], firstfound, pkgdb, fas, branches)
|
||||||
if package:
|
if package:
|
||||||
try:
|
try:
|
||||||
create_branches(package, options.pkghost, options.pkghostlocal)
|
create_branches(package, options.pkghost, options.pkghostlocal)
|
||||||
|
@ -766,7 +768,7 @@ if __name__ == '__main__':
|
||||||
if not more:
|
if not more:
|
||||||
break
|
break
|
||||||
elif type == 'change':
|
elif type == 'change':
|
||||||
(package, more) = process_change_request(i, j, comments['bugs'][str(i.bug_id)]['comments'], firstfound, pkgdb, branches)
|
(package, more) = process_change_request(i, j, comments['bugs'][str(i.id)]['comments'], firstfound, pkgdb, branches)
|
||||||
if package:
|
if package:
|
||||||
try:
|
try:
|
||||||
create_branches(package, options.pkghost, options.pkghostlocal)
|
create_branches(package, options.pkghost, options.pkghostlocal)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue