Merge lp:~raof/ubuntu-archive-tools/python3 into lp:ubuntu-archive-tools

Proposed by Chris Halse Rogers
Status: Merged
Merged at revision: 1271
Proposed branch: lp:~raof/ubuntu-archive-tools/python3
Merge into: lp:ubuntu-archive-tools
Diff against target: 58 lines (+7/-9)
1 file modified
sru-release (+7/-9)
To merge this branch: bzr merge lp:~raof/ubuntu-archive-tools/python3
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+378216@code.launchpad.net

Commit message

Port sru-release to python3

Description of the change

Focal has dropped python2-launchpadlib, so ubuntu-archive-tools doesn't work there.
The simple 2to3 patch almost works, with a little manual fixup for bytes-vs-str.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Needs Fixing
1267. By Christopher James Halse Rogers <email address hidden>

sru-release: Port to python3

Revision history for this message
Chris Halse Rogers (raof) wrote :

How's this?

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sru-release'
2--- sru-release 2020-01-25 02:19:13 +0000
3+++ sru-release 2020-01-29 04:03:21 +0000
4@@ -1,4 +1,4 @@
5-#!/usr/bin/python2.7
6+#!/usr/bin/python3
7
8 # Copyright (C) 2011, 2012 Canonical Ltd.
9 # Author: Martin Pitt <martin.pitt@canonical.com>
10@@ -36,10 +36,8 @@
11 import time
12 import unittest
13
14-try:
15- from urllib.request import urlopen
16-except ImportError:
17- from urllib import urlopen
18+from six.moves.urllib.request import urlopen
19+from io import TextIOWrapper
20
21 from launchpadlib.launchpad import Launchpad
22
23@@ -136,7 +134,7 @@
24 return bugs
25
26 # Load changesfile
27- changelog = urlopen(changesfileurl)
28+ changelog = TextIOWrapper(urlopen(changesfileurl), encoding='utf-8')
29 bugnums = []
30 for l in changelog:
31 if l.startswith('Launchpad-Bugs-Fixed: '):
32@@ -251,7 +249,7 @@
33 sys.stderr.write(message)
34 sys.exit(1)
35
36- for pkg, versions in pkg_versions_map[package].iteritems():
37+ for pkg, versions in pkg_versions_map[package].items():
38 print('--- Releasing %s ---' % pkg)
39 print('Proposed: %s' % versions['proposed'])
40 if 'security' in versions:
41@@ -323,7 +321,7 @@
42 # If everything went well, update the bugs
43 if not options.no_bugs:
44 for pkg_versions in pkg_versions_map.values():
45- for pkg, versions in pkg_versions.iteritems():
46+ for pkg, versions in pkg_versions.items():
47 sru_bugs = match_srubugs(options, versions['changesfile'])
48 tag = 'verification-needed-%s' % release
49 for sru_bug in sru_bugs:
50@@ -353,7 +351,7 @@
51 date = datetime.datetime.now().ctime()
52 unblock_string = '# %s %s\n' % (timestamp, date)
53 unblock_string += ''.join(['unblock %s/%s\n' % (pkg, ver)
54- for pkg, ver in packages.iteritems()])
55+ for pkg, ver in packages.items()])
56 unblock_string += '\n'
57 # Update and commit the hint
58 with open(hints_file, 'a+') as f:

Subscribers

People subscribed via source and target branches