diff options
Diffstat (limited to 'batch-stabilize.py')
-rwxr-xr-x | batch-stabilize.py | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/batch-stabilize.py b/batch-stabilize.py index 053cd19..155af38 100755 --- a/batch-stabilize.py +++ b/batch-stabilize.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Copyright 2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 @@ -11,8 +11,8 @@ import re import shutil import subprocess import sys +import xmlrpc.client -from bugz.bugzilla import BugzillaProxy from common import login import portage.versions @@ -20,7 +20,7 @@ BUG_REGEX = re.compile("[Bb]ug #?(\d+)") def print_and_log(message, log): try: - print message + print(message) log.write(message + '\n') finally: log.flush() @@ -40,7 +40,7 @@ def run_command(args, cwd, log): log.flush() def save_state(done_bugs): - with open('batch-stabilize.state', 'w') as state_file: + with open('batch-stabilize.state', 'wb') as state_file: pickle.dump(done_bugs, state_file) if __name__ == "__main__": @@ -62,12 +62,12 @@ if __name__ == "__main__": done_bugs = [] if os.path.exists('batch-stabilize.state'): - with open('batch-stabilize.state', 'r') as state_file: - done_bugs = pickle.load(state_file) + with open('batch-stabilize.state', 'rb') as state_file: + done_bugs = pickle.load(state_file, fix_imports=True) url = 'https://bugs.gentoo.org/xmlrpc.cgi' - print 'You will be prompted for your Gentoo Bugzilla username and password (%s).' % url - bugzilla = BugzillaProxy(url) + print('You will be prompted for your Gentoo Bugzilla username and password (%s).' % url) + bugzilla = xmlrpc.client.ServerProxy(url) user, login_data = login(bugzilla) with open(options.input_filename, "r") as input_file: @@ -83,14 +83,14 @@ if __name__ == "__main__": if line.startswith("#"): match = BUG_REGEX.search(line, re.IGNORECASE) if not match: - print 'Ignoring comment line [%s]...' % line + print('Ignoring comment line [%s]...' % line) continue else: bug_id = int(match.group(1)) continue if bug_id == -1: - print 'Could not recognize bug id' + print('Could not recognize bug id') sys.exit(1) # Drop the leading '='. @@ -109,10 +109,10 @@ if __name__ == "__main__": for (pn, ebuild_name) in stabilization_dict[bug_id]: ebuild_path = os.path.join(options.repo, pn, ebuild_name) if not os.path.exists(ebuild_path): - print '%s: file does not exist' % ebuild_path + print('%s: file does not exist' % ebuild_path) success = False if not success: - print 'Sanity check failed. Please make sure your CVS repo is up to date (cvs up).' + print('Sanity check failed. Please make sure your CVS repo is up to date (cvs up).') sys.exit(1) with open('batch-stabilize.log', 'a') as log_file: @@ -132,20 +132,20 @@ if __name__ == "__main__": try: shutil.rmtree(cvs_path) except OSError: - print '!!! rmtree %s failed' % cvs_path + print('!!! rmtree %s failed' % cvs_path) sys.exit(1) if run_command(["cvs", "up", pn], options.repo, log_file)[0] != 0: - print '!!! cvs up failed' + print('!!! cvs up failed') sys.exit(1) for (pn, ebuild_name) in stabilization_dict[bug_id]: cvs_path = os.path.join(options.repo, pn) print_and_log('Working in %s...' % cvs_path, log_file) if run_command(["ekeyword", options.arch, ebuild_name], cvs_path, log_file)[0] != 0: - print '!!! ekeyword failed' + print('!!! ekeyword failed') sys.exit(1) if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0: - print '!!! repoman manifest failed' + print('!!! repoman manifest failed') sys.exit(1) for (pn, ebuild_name) in stabilization_dict[bug_id]: cvs_path = os.path.join(options.repo, pn) @@ -160,12 +160,13 @@ if __name__ == "__main__": if run_command(["echangelog", commit_message], cvs_path, log_file)[0] != 0: print_and_log('echangelog failed, maybe just the Manifest is being updated; continuing', log_file) if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0: - print '!!! repoman manifest failed' + print('!!! repoman manifest failed') sys.exit(1) if run_command(["repoman", "commit", "--ignore-arches", "-m", commit_message], cvs_path, log_file)[0] != 0: - print '!!! repoman commit failed' + print('!!! repoman commit failed') sys.exit(1) params = {} + params['Bugzilla_token'] = login_data['token'] params['ids'] = [bug_id] bug_xml = bugzilla.Bug.get(params)['bugs'][0] has_my_arch = False @@ -188,7 +189,7 @@ if __name__ == "__main__": # We don't close bugs which still have other arches for obvious reasons, # and security bugs because stabilization is not the last step for them. params = {} - params['token'] = login_data['token'] + params['Bugzilla_token'] = login_data['token'] params['ids'] = [bug_id] params['cc'] = {} params['cc']['remove'] = ['%s@gentoo.org' % options.arch] @@ -209,3 +210,7 @@ if __name__ == "__main__": if os.path.exists('batch-stabilize.state'): os.remove('batch-stabilize.state') + + params = {} + params['Bugzilla_token'] = login_data['token'] + bugzilla.User.logout(params) |