summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'stabilization-candidates.py')
-rwxr-xr-xstabilization-candidates.py54
1 files changed, 31 insertions, 23 deletions
diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 52c88f1..d324bdb 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.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
@@ -8,10 +8,8 @@ import os.path
import random
import re
import subprocess
-import xmlrpclib
-import urllib
+import xmlrpc.client
-from bugz.bugzilla import BugzillaProxy
from portage.package.ebuild.getmaskingstatus import getmaskingstatus
from portage.xml.metadata import MetaDataXML
import portage.versions
@@ -36,9 +34,9 @@ if __name__ == "__main__":
parser.error("unrecognized command-line args")
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)
final_candidates = []
now = datetime.datetime.now()
@@ -77,7 +75,7 @@ if __name__ == "__main__":
best_stable = portage.versions.best(portage.portdb.match(cp))
if not best_stable:
continue
- print 'Working on %s...' % cp,
+ print('Working on %s...' % cp, end=' ')
candidates = []
for cpv in portage.portdb.cp_list(cp):
# Only consider higher versions than best stable.
@@ -100,12 +98,12 @@ if __name__ == "__main__":
continue
# Eliminate hard masked packages among others.
- if getmaskingstatus(cpv) not in [[u'~%s keyword' % arch] for arch in options.arch]:
+ if getmaskingstatus(cpv) not in [['~%s keyword' % arch] for arch in options.arch]:
continue
candidates.append(cpv)
if not candidates:
- print 'no candidates'
+ print('no candidates')
continue
candidates.sort(key=portage.versions.cpv_sort_key())
@@ -122,14 +120,14 @@ if __name__ == "__main__":
regex = '\*%s \((.*)\)' % re.escape(pv)
match = re.search(regex, changelog_file.read())
if not match:
- print 'error parsing ChangeLog'
+ print('error parsing ChangeLog')
continue
changelog_date = datetime.datetime.strptime(match.group(1), '%d %b %Y')
if now - changelog_date < datetime.timedelta(days=options.days):
- print 'not old enough'
+ print('not old enough')
continue
- except IOError, e:
- print e
+ except IOError as e:
+ print(e)
continue
keywords = portage.db["/"]["porttree"].dbapi.aux_get(best_candidate, ['KEYWORDS'])[0]
@@ -139,19 +137,25 @@ if __name__ == "__main__":
missing_arch = True
break
if missing_arch:
- print 'not keyworded ~arch'
+ print('not keyworded ~arch')
continue
# Do not risk trying to stabilize a package with known bugs.
- bugs = [x for x in bugzilla.Bug.search({'summary': cp})['bugs'] if x['is_open'] and x['severity'] not in ['enhancement', 'QA']]
+ params = {}
+ params['Bugzilla_token'] = login_data['token']
+ params['summary'] = cp
+ bugs = [x for x in bugzilla.Bug.search(params)['bugs'] if x['is_open'] and x['severity'] not in ['enhancement', 'QA']]
if bugs:
- print 'has bugs'
+ print('has bugs')
continue
# Protection against filing a stabilization bug twice.
- bugs = bugzilla.Bug.search({'summary': best_candidate})['bugs']
+ params = {}
+ params['Bugzilla_token'] = login_data['token']
+ params['summary'] = best_candidate
+ bugs = bugzilla.Bug.search(params)['bugs']
if bugs:
- print 'version has bugs'
+ print('version has bugs')
continue
ebuild_name = portage.versions.catsplit(best_candidate)[1] + ".ebuild"
@@ -160,8 +164,8 @@ if __name__ == "__main__":
try:
original_contents = open(ebuild_path).read()
manifest_contents = open(manifest_path).read()
- except IOError, e:
- print e
+ except IOError as e:
+ print(e)
continue
try:
for arch in options.arch:
@@ -169,7 +173,7 @@ if __name__ == "__main__":
subprocess.check_output(["repoman", "manifest"], cwd=cvs_path)
subprocess.check_output(["repoman", "full"], cwd=cvs_path)
except subprocess.CalledProcessError:
- print 'repoman error'
+ print('repoman error')
continue
finally:
f = open(ebuild_path, "w")
@@ -182,4 +186,8 @@ if __name__ == "__main__":
with open(options.output_filename, 'a') as f:
f.write('# %s %s\n' % (maintainer, ', '.join(other_maintainers)))
f.write('%s\n' % best_candidate)
- print (best_candidate, maintainer, other_maintainers)
+ print((best_candidate, maintainer, other_maintainers))
+
+ params = {}
+ params['Bugzilla_token'] = login_data['token']
+ bugzilla.User.logout(params)