diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2014-12-13 13:33:09 -0600 |
---|---|---|
committer | Pawel Hajdan, Jr <phajdan.jr@gentoo.org> | 2014-12-29 15:52:27 +0100 |
commit | 842f3d251d81ffc274fa01a1d9ba9b5794a2d714 (patch) | |
tree | 8754a07f108bb8715a2c83c4f0fdd25c485c33e2 /file-stabilization-bugs.py | |
parent | Fix issue in batch-stabilize leading to errors from Bugzilla (diff) | |
download | arch-tools-842f3d251d81ffc274fa01a1d9ba9b5794a2d714.tar.gz arch-tools-842f3d251d81ffc274fa01a1d9ba9b5794a2d714.tar.bz2 arch-tools-842f3d251d81ffc274fa01a1d9ba9b5794a2d714.zip |
Port most tools to python 3
This commit ports the following tools to python 3.
- common code
- batch-stabilize
- file-stabilization-bugs
- maintainer-timeout
- reverse-dependencies
- stabilization-candidates
This is a list of the changes:
- Remove the dependency on pybugz; these tools now use xmlrpc.client
directly. This is needed because the next release of pybugz does the
same thing; we no longer have a bugzilla module since it was just a
wrapper.
Handle tokens correctly:
- When we log into Bugzilla, we are given a
token we must pass back to it with every command we issue.
- Log out at the end of every session to expire the token.
Fix the state file processing:
- The pickle module handles binary files, not text files, so read and
write the state file in binary mode.
- Add fix_imports=True when reading the state file so a python-2
compatible state file can be read.
- Do not set the URL for a stabilization request
X-Gentoo-Bug: 532054
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=532054
X-Gentoo-Bug: 532368
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=532368
Diffstat (limited to 'file-stabilization-bugs.py')
-rwxr-xr-x | file-stabilization-bugs.py | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/file-stabilization-bugs.py b/file-stabilization-bugs.py index 1c5bbe9..f9b170c 100755 --- a/file-stabilization-bugs.py +++ b/file-stabilization-bugs.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Copyright 2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 @@ -11,16 +11,14 @@ import re import shutil import subprocess import sys -import urllib -import xmlrpclib +import xmlrpc.client -from bugz.bugzilla import BugzillaProxy from common import login import portage.versions from portage.xml.metadata import MetaDataXML def save_state(done_cpvs): - with open('file-stabilization-bugs.state', 'w') as state_file: + with open('file-stabilization-bugs.state', 'wb') as state_file: pickle.dump(done_cpvs, state_file) if __name__ == "__main__": @@ -40,13 +38,13 @@ if __name__ == "__main__": done_cpvs = [] if os.path.exists('file-stabilization-bugs.state'): - with open('file-stabilization-bugs.state', 'r') as state_file: - done_cpvs = pickle.load(state_file) + with open('file-stabilization-bugs.state', 'rb') as state_file: + done_cpvs = 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) - login(bugzilla) + 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: for line in input_file: @@ -58,7 +56,7 @@ if __name__ == "__main__": cpv = line if cpv in done_cpvs: - print 'Skipping %s because it\'s marked as done' % cpv + print('Skipping %s because it\'s marked as done' % cpv) continue cp = portage.versions.pkgsplit(cpv)[0] @@ -75,37 +73,41 @@ if __name__ == "__main__": description = ('Is it OK to stabilize =%s ?\n' % cpv + 'If so, please CC all arches which have stable keywords\n' + 'for older versions of this package.') - url = 'http://packages.gentoo.org/package/%s?arches=linux' % urllib.quote(cp) params = {} + params['Bugzilla_token'] = login_data['token'] params['product'] = 'Gentoo Linux' params['version'] = 'unspecified' params['component'] = 'Keywording and Stabilization' params['summary'] = '%s: stabilization request' % cpv params['description'] = description - params['url'] = url params['assigned_to'] = maintainer params['cc'] = other_maintainers params['severity'] = 'enhancement' try: bug_id = bugzilla.Bug.create(params)['id'] - print 'Submitted bug #%d for %s. ;-)' % (bug_id, cpv) + print('Submitted bug #%d for %s. ;-)' % (bug_id, cpv)) done_cpvs += cpv save_state(done_cpvs) try: params = {} + params['Bugzilla_token'] = login_data['token'] params['ids'] = [bug_id] params['keywords'] = {'set': 'STABLEREQ'} bugzilla.Bug.update(params) - except xmlrpclib.Fault, f: + except xmlrpc.client.Fault as f: exit_code = 1 - print f - print 'Failed to add STABLEREQ keyword for %s. :-/' % cpv - except xmlrpclib.Fault, f: + print(f) + print('Failed to add STABLEREQ keyword for %s. :-/' % cpv) + except xmlrpc.client.Fault as f: exit_code = 1 - print f - print 'Failed to submit bug for %s. :-(' % cpv + print(f) + print('Failed to submit bug for %s. :-(' % cpv) if exit_code == 0 and os.path.exists('file-stabilization-bugs.state'): os.remove('file-stabilization-bugs.state') + params = {} + params['Bugzilla_token'] = login_data['token'] + bugzilla.User.logout(params) + sys.exit(exit_code) |