Merge lp:~jelmer/hydrazine/trunk into lp:hydrazine
- trunk
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Merged |
---|---|
Approved by: | Martin Pool |
Approved revision: | 107 |
Merged at revision: | 107 |
Proposed branch: | lp:~jelmer/hydrazine/trunk |
Merge into: | lp:hydrazine |
Diff against target: |
901 lines (+153/-165) 10 files modified
README (+2/-2) bugclient (+62/-62) capture-bug-counts (+5/-5) check-membership (+4/-4) feed-pqm (+46/-58) lp-attach (+9/-9) lp-delete-ppa-packages (+3/-3) lp-promote-ppa (+9/-9) scan-merge-proposals (+11/-11) setup.py (+2/-2) |
To merge this branch: | bzr merge lp:~jelmer/hydrazine/trunk |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Pool | Approve | ||
Review via email: mp+402141@code.launchpad.net |
Commit message
Initial work on a port to Python 3.
Description of the change
Initial work on port to Python 3.
I haven't tested all tools in depth yet, but this is sufficient to at least
be able to run each one of them without syntax errors and to make
brz's bug checking script happy.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'README' |
2 | --- README 2013-03-23 23:14:17 +0000 |
3 | +++ README 2021-05-03 12:32:54 +0000 |
4 | @@ -6,8 +6,8 @@ |
5 | |
6 | It depends on: |
7 | |
8 | - * launchpadlib |
9 | - * bzrlib (in the bzr package) |
10 | + * launchpadlib (in the python3-launchpadlib package) |
11 | + * breezy (in the python3-breezy package) |
12 | |
13 | It's rough but useful. Bugs and merge requests welcome through |
14 | <https://launchpad.net/hydrazine/>. |
15 | |
16 | === modified file 'bugclient' |
17 | --- bugclient 2013-03-23 22:49:55 +0000 |
18 | +++ bugclient 2021-05-03 12:32:54 +0000 |
19 | @@ -1,4 +1,4 @@ |
20 | -#! /usr/bin/python |
21 | +#! /usr/bin/python3 |
22 | |
23 | # Copyright (C) 2010 Martin Pool |
24 | |
25 | @@ -34,7 +34,7 @@ |
26 | return self.enums |
27 | |
28 | def show_valid(self): |
29 | - print "Sorry, valid entries are:" |
30 | + print("Sorry, valid entries are:") |
31 | _show_columnated(self.enums) |
32 | |
33 | status_enum = NamedEnum(['Confirmed', 'Triaged', 'Fix Committed', |
34 | @@ -75,7 +75,7 @@ |
35 | if self._needs_pillar(): return |
36 | kwargs = {} |
37 | if not self.filters: |
38 | - print 'No filter set?' |
39 | + print('No filter set?') |
40 | return |
41 | for f in self.filters: |
42 | if f == "milestone": |
43 | @@ -94,7 +94,7 @@ |
44 | kwargs['order_by'] = '-datecreated' |
45 | self.task_list = self.pillar.searchTasks(**kwargs) |
46 | |
47 | - if 'regexp' in self.filters.keys(): |
48 | + if 'regexp' in list(self.filters.keys()): |
49 | new_task_list = [] |
50 | for t in self.task_list: |
51 | # FIXME: can be expanded to search descriptions, if needed |
52 | @@ -107,12 +107,12 @@ |
53 | self.search_index = 0 |
54 | self._select_bug(first_bug_task.bug, "quiet") |
55 | except IndexError: |
56 | - print "No bugtasks found" |
57 | + print("No bugtasks found") |
58 | return |
59 | |
60 | args = line.split() |
61 | if not args: |
62 | - print "Task list loaded" |
63 | + print("Task list loaded") |
64 | self._show_bug(self.bug) |
65 | return |
66 | |
67 | @@ -131,12 +131,12 @@ |
68 | try: |
69 | bug_number = int(bug_number) |
70 | except ValueError: |
71 | - print 'usage: bzr NUMBER' |
72 | + print('usage: bzr NUMBER') |
73 | return |
74 | try: |
75 | the_bug = self.session.bugs[bug_number] |
76 | except KeyError: |
77 | - print 'no such bug?' |
78 | + print('no such bug?') |
79 | return |
80 | self._select_bug(the_bug) |
81 | |
82 | @@ -144,16 +144,16 @@ |
83 | """Post a comment to the current bug.""" |
84 | if self._needs_bug(): return |
85 | if not line: |
86 | - print "Please specify a comment" |
87 | + print("Please specify a comment") |
88 | return |
89 | result = self.bug.newMessage(content=line) |
90 | - print "Posted message: %s" % result |
91 | + print(("Posted message: %s" % result)) |
92 | |
93 | def do_description(self, nothing): |
94 | """Show bug description""" |
95 | if self._needs_bug(): |
96 | return |
97 | - print self.bug.description |
98 | + print((self.bug.description)) |
99 | |
100 | def do_duplicate(self, duplicate_id): |
101 | """Mark as a duplicate""" |
102 | @@ -162,18 +162,18 @@ |
103 | try: |
104 | duplicate_id = int(duplicate_id) |
105 | except ValueError: |
106 | - print 'usage: duplicate BUG_NUMBER' |
107 | + print('usage: duplicate BUG_NUMBER') |
108 | return |
109 | # XXX: could just synthesize a URL, which might be faster; probably |
110 | # need to make sure the root lines up correctly |
111 | try: |
112 | duplicate_bug = self.session.bugs[duplicate_id] |
113 | except KeyError: |
114 | - print 'no such bug?' |
115 | + print('no such bug?') |
116 | return |
117 | - print 'marking %d as a duplicate of %d' % (self.current_bug_number, |
118 | - duplicate_bug.id) |
119 | - print ' "%s"' % duplicate_bug.title |
120 | + print(('marking %d as a duplicate of %d' % (self.current_bug_number, |
121 | + duplicate_bug.id))) |
122 | + print((' "%s"' % duplicate_bug.title)) |
123 | # used to use markAsDuplicate but see bug 680339 |
124 | self.bug.duplicate_of = duplicate_bug |
125 | self.bug.lp_save() |
126 | @@ -216,8 +216,8 @@ |
127 | elif args[0] == "regexp": |
128 | try: |
129 | re.compile(' '.join(args[1:])) |
130 | - except re.error, e: |
131 | - print "regexp error: %s" % e |
132 | + except re.error as e: |
133 | + print(("regexp error: %s" % e)) |
134 | return |
135 | elif args[0] == "tags_combinator": |
136 | val = tags_combinator_enum.get(' '.join(args[1:])) |
137 | @@ -237,17 +237,17 @@ |
138 | if new_importance is None: |
139 | importance_enum.show_valid() |
140 | return |
141 | - print '#%d changing importance %s => %s' % (self.bug.id, task.importance, new_importance) |
142 | + print(('#%d changing importance %s => %s' % (self.bug.id, task.importance, new_importance))) |
143 | task.importance = new_importance |
144 | if opts.debug: |
145 | - print '**** before save' |
146 | - print task._wadl_resource._definition.representation |
147 | + print('**** before save') |
148 | + print((task._wadl_resource._definition.representation)) |
149 | try: |
150 | task.lp_save() |
151 | except: |
152 | - print '**** got error' |
153 | + print('**** got error') |
154 | if opts.debug: |
155 | - print task._wadl_resource._definition.representation |
156 | + print((task._wadl_resource._definition.representation)) |
157 | |
158 | def do_milestone(self, line): |
159 | """Set milestone""" |
160 | @@ -256,7 +256,7 @@ |
161 | if task is None: |
162 | return |
163 | if not line: |
164 | - print 'No milestone specified?' |
165 | + print('No milestone specified?') |
166 | return |
167 | |
168 | milestone = '%s/+milestone/%s' % (self.pillar, line) |
169 | @@ -266,13 +266,13 @@ |
170 | def do_next(self, show): |
171 | """Go to the next bug in the list""" |
172 | if self.task_list is None: |
173 | - print 'no list loaded; use a filter and batch to load a list' |
174 | + print('no list loaded; use a filter and batch to load a list') |
175 | return |
176 | self.search_index += 1 |
177 | try: |
178 | bug_task = self.task_list[self.search_index] |
179 | except IndexError: |
180 | - print "End of bug list" |
181 | + print("End of bug list") |
182 | return |
183 | if show == "": |
184 | show = "show" |
185 | @@ -283,9 +283,9 @@ |
186 | if self._needs_pillar(): return |
187 | tags = self.pillar.official_bug_tags |
188 | if not tags: |
189 | - print 'No official bug tags for %s' % self.pillar.name |
190 | + print('No official bug tags for %s' % self.pillar.name) |
191 | return |
192 | - print 'Official bug tags for %s' % self.pillar.name |
193 | + print('Official bug tags for %s' % self.pillar.name) |
194 | _show_columnated(tags) |
195 | |
196 | def do_open(self, ignored): |
197 | @@ -309,15 +309,15 @@ |
198 | task = self._needs_single_task() |
199 | if task is None: return |
200 | if not to_pillar: |
201 | - print 'usage: retarget TO_PILLAR' |
202 | + print('usage: retarget TO_PILLAR') |
203 | return |
204 | new_target = self._find_pillar(to_pillar) |
205 | if new_target is None: |
206 | - print 'no such product?' |
207 | + print('no such product?') |
208 | return |
209 | - print 'change target of bug %s' % (task.bug.id,) |
210 | - print ' from: %s' % (task.target,) |
211 | - print ' to: %s' % (new_target,) |
212 | + print('change target of bug %s' % (task.bug.id,)) |
213 | + print(' from: %s' % (task.target,)) |
214 | + print(' to: %s' % (new_target,)) |
215 | task.target = new_target |
216 | task.lp_save() |
217 | |
218 | @@ -338,8 +338,8 @@ |
219 | """ |
220 | if self._needs_bug(): |
221 | return |
222 | - print 'changing title of bug %d to "%s"' % (self.bug.id, new_title) |
223 | - print ' old title "%s"' % (self.bug.title) |
224 | + print('changing title of bug %d to "%s"' % (self.bug.id, new_title)) |
225 | + print(' old title "%s"' % (self.bug.title)) |
226 | self.bug.title = new_title |
227 | self.bug.lp_save() |
228 | |
229 | @@ -355,7 +355,7 @@ |
230 | if new_status is None: |
231 | status_enum.show_valid() |
232 | return |
233 | - print '#%d changing status %s => %s' % (self.bug.id, task.status, new_status) |
234 | + print('#%d changing status %s => %s' % (self.bug.id, task.status, new_status)) |
235 | task.status = new_status |
236 | task.lp_save() |
237 | |
238 | @@ -371,7 +371,7 @@ |
239 | """ |
240 | if self._needs_bug(): return |
241 | if not line.strip(): |
242 | - print 'bug %d tags: %s' % (self.bug.id, ' '.join(self.bug.tags)) |
243 | + print('bug %d tags: %s' % (self.bug.id, ' '.join(self.bug.tags))) |
244 | return |
245 | to_add = [] |
246 | to_remove = [] |
247 | @@ -391,9 +391,9 @@ |
248 | for a in to_remove: |
249 | if a in new_tags: |
250 | new_tags.remove(a) |
251 | - print 'changing bug %d tags' % self.bug.id |
252 | - print ' from: %s' % ' '.join(old_tags) |
253 | - print ' to: %s' % ' '.join(new_tags) |
254 | + print('changing bug %d tags' % self.bug.id) |
255 | + print(' from: %s' % ' '.join(old_tags)) |
256 | + print(' to: %s' % ' '.join(new_tags)) |
257 | self.bug.tags = new_tags |
258 | self.bug.lp_save() |
259 | |
260 | @@ -406,7 +406,7 @@ |
261 | if self._needs_bug(): return |
262 | task = self._needs_single_task() |
263 | if not task: |
264 | - print 'no task selected' |
265 | + print('no task selected') |
266 | return |
267 | for w in line.split(): |
268 | if w[0] == '+': |
269 | @@ -432,24 +432,24 @@ |
270 | # can't use super because Cmd is an old-style |
271 | # class |
272 | return cmd.Cmd.onecmd(self, cmdline) |
273 | - except lazr.restfulclient.errors.RestfulError, e: |
274 | - print e |
275 | + except lazr.restfulclient.errors.RestfulError as e: |
276 | + print(e) |
277 | pass |
278 | |
279 | def _needs_bug(self): |
280 | if self.bug is None: |
281 | - print 'no bug selected' |
282 | + print('no bug selected') |
283 | return True |
284 | |
285 | def _needs_pillar(self): |
286 | if self.pillar is None: |
287 | - print 'no pillar selected' |
288 | + print('no pillar selected') |
289 | return True |
290 | |
291 | def _needs_single_task(self): |
292 | """Return the single task for the current bug in the current pillar, or None""" |
293 | if self.bug is None: |
294 | - print 'no bug selected' |
295 | + print('no bug selected') |
296 | return None |
297 | tasks = list(self.bug.bug_tasks) |
298 | if self.pillar is None: |
299 | @@ -457,14 +457,14 @@ |
300 | # no pillar; assume this is ok |
301 | return tasks[0] |
302 | else: |
303 | - print 'This bug has multiple tasks; please choose a pillar' |
304 | + print('This bug has multiple tasks; please choose a pillar') |
305 | return None |
306 | else: |
307 | for t in tasks: |
308 | if t.target.self_link == self.pillar.self_link: |
309 | return t |
310 | else: |
311 | - print 'No task for %s in %s' % (self.pillar, self.bug) |
312 | + print('No task for %s in %s' % (self.pillar, self.bug)) |
313 | return None |
314 | |
315 | @property |
316 | @@ -495,43 +495,43 @@ |
317 | try: |
318 | return pillar_collection[0] |
319 | except IndexError: |
320 | - print "No such pillar?" |
321 | + print("No such pillar?") |
322 | return |
323 | |
324 | def _select_pillar(self, pillar): |
325 | self.pillar = pillar |
326 | if pillar is None: |
327 | - print "no pillar selected" |
328 | + print("no pillar selected") |
329 | else: |
330 | - print " %s" % self.pillar |
331 | + print(" %s" % self.pillar) |
332 | |
333 | def _show_bug(self, bug): |
334 | - print 'bug: %d: %s' % (bug.id, bug.title) |
335 | + print('bug: %d: %s' % (bug.id, bug.title)) |
336 | if bug.duplicate_of: |
337 | - print ' duplicate of bug %d' % (bug.duplicate_of.id,) |
338 | + print(' duplicate of bug %d' % (bug.duplicate_of.id,)) |
339 | else: |
340 | for task in bug.bug_tasks: |
341 | - print ' affects %-40s %14s %s' % ( |
342 | - task.bug_target_name, task.status, task.importance,) |
343 | + print(' affects %-40s %14s %s' % ( |
344 | + task.bug_target_name, task.status, task.importance,)) |
345 | if task.milestone: |
346 | - print ' milestone: %s' % task.milestone.name |
347 | - print ' tags: %s' % ' '.join(bug.tags) |
348 | + print(' milestone: %s' % task.milestone.name) |
349 | + print(' tags: %s' % ' '.join(bug.tags)) |
350 | |
351 | def _show_columnated(tags): |
352 | tags = tags[:] |
353 | - longest = max(map(len, tags)) |
354 | + longest = max(list(map(len, tags))) |
355 | cols = int(os.environ.get('COLUMNS', '80')) |
356 | per_row = max(int((cols-1)/(longest + 1)), 1) |
357 | i = 0 |
358 | while tags: |
359 | t = tags.pop(0) |
360 | - print '%-*s' % (longest, t), |
361 | + print('%-*s' % (longest, t), end=' ') |
362 | i += 1 |
363 | if i == per_row: |
364 | |
365 | + print() |
366 | i = 0 |
367 | if i != 0: |
368 | |
369 | + print() |
370 | |
371 | |
372 | def main(argv): |
373 | @@ -564,7 +564,7 @@ |
374 | cmd._connect() |
375 | |
376 | for c in opts.commands or []: |
377 | - print '> ' + c |
378 | + print('> ' + c) |
379 | if cmd.onecmd(c): |
380 | break |
381 | else: |
382 | |
383 | === modified file 'capture-bug-counts' |
384 | --- capture-bug-counts 2013-03-23 22:49:55 +0000 |
385 | +++ capture-bug-counts 2021-05-03 12:32:54 +0000 |
386 | @@ -1,4 +1,4 @@ |
387 | -#! /usr/bin/python |
388 | +#! /usr/bin/python3 |
389 | |
390 | import sys |
391 | |
392 | @@ -70,10 +70,10 @@ |
393 | def show_text(self): |
394 | # print self.get_name() |
395 | for category in self.query_categories(): |
396 | - print '%6d %s %s' % (category.count_bugs(), |
397 | + print('%6d %s %s' % (category.count_bugs(), |
398 | category.get_name(), |
399 | - category.get_link_url() or '') |
400 | |
401 | + category.get_link_url() or '')) |
402 | + print() |
403 | |
404 | |
405 | class PatchCannedQuery(CannedQuery): |
406 | @@ -103,7 +103,7 @@ |
407 | if bugtask.status not in by_status: |
408 | by_status[bugtask.status] = StatusBugCategory(bugtask.status) |
409 | by_status[bugtask.status].add(bugtask) |
410 | - return by_status.values() |
411 | + return list(by_status.values()) |
412 | |
413 | |
414 | def show_bug_report(project): |
415 | |
416 | === modified file 'check-membership' |
417 | --- check-membership 2010-12-02 00:02:43 +0000 |
418 | +++ check-membership 2021-05-03 12:32:54 +0000 |
419 | @@ -1,4 +1,4 @@ |
420 | -#! /usr/bin/python |
421 | +#! /usr/bin/python3 |
422 | # |
423 | # Copyright (C) 2009 Canonical Ltd |
424 | |
425 | @@ -17,7 +17,7 @@ |
426 | |
427 | def main(argv): |
428 | if len(argv) != 3: |
429 | - print __doc__ |
430 | + print(__doc__) |
431 | return 2 |
432 | user_name = argv[1] |
433 | group_name = argv[2] |
434 | @@ -25,10 +25,10 @@ |
435 | user = launchpad.people[user_name] |
436 | for user_team in user.super_teams: |
437 | if user_team.name == group_name: |
438 | - print '%s is a member of %s' % (user_name, group_name) |
439 | + print('%s is a member of %s' % (user_name, group_name)) |
440 | return 0 |
441 | else: |
442 | - print '%s is not a member of %s' % (user_name, group_name) |
443 | + print('%s is not a member of %s' % (user_name, group_name)) |
444 | return 1 |
445 | |
446 | |
447 | |
448 | === modified file 'feed-pqm' |
449 | --- feed-pqm 2011-12-21 11:25:36 +0000 |
450 | +++ feed-pqm 2021-05-03 12:32:54 +0000 |
451 | @@ -1,4 +1,4 @@ |
452 | -#! /usr/bin/python |
453 | +#! /usr/bin/python3 |
454 | # vi: expandtab:sts=4 |
455 | |
456 | # Copyright (C) 2010 Martin Pool |
457 | @@ -19,29 +19,21 @@ |
458 | import optparse |
459 | import sys |
460 | |
461 | -try: |
462 | - from bzrlib import initialize as bzrlib_initialize |
463 | -except ImportError: |
464 | - import bzrlib.ui |
465 | - def bzrlib_setup(): |
466 | - """Setup bzrlib ui for older bzr versions without bzrlib.initialize""" |
467 | - bzrlib.ui.ui_factory = bzrlib.ui.make_ui_for_terminal( |
468 | - sys.stdin, sys.stdout, sys.stderr) |
469 | -else: |
470 | - import atexit |
471 | - def bzrlib_setup(): |
472 | - """Call bzrlib.initialize and register cleanup to be run on exit""" |
473 | - context = bzrlib_initialize() |
474 | - if context is not None: |
475 | - atexit.register(context.__enter__().__exit__, None, None, None) |
476 | +from breezy import initialize as breezy_initialize |
477 | +import atexit |
478 | +def breezy_setup(): |
479 | + """Call breezy.initialize and register cleanup to be run on exit""" |
480 | + context = breezy_initialize() |
481 | + if context is not None: |
482 | + atexit.register(context.__enter__().__exit__, None, None, None) |
483 | |
484 | -from bzrlib.email_message import EmailMessage |
485 | -from bzrlib import ( |
486 | +from breezy.email_message import EmailMessage |
487 | +from breezy import ( |
488 | config as _mod_config, |
489 | gpg, |
490 | - version_info as bzrlib_version, |
491 | + version_info as breezy_version, |
492 | ) |
493 | -from bzrlib.smtp_connection import SMTPConnection |
494 | +from breezy.smtp_connection import SMTPConnection |
495 | |
496 | import hydrazine |
497 | |
498 | @@ -51,12 +43,12 @@ |
499 | |
500 | |
501 | def read_choice(): |
502 | - print 'What now?', |
503 | + print('What now?', end='') |
504 | return raw_input() |
505 | |
506 | |
507 | def show_help(): |
508 | - print """\ |
509 | + print("""\ |
510 | feed-pqm looks for approved merge proposals and sends them to pqm. |
511 | |
512 | commands: |
513 | @@ -69,7 +61,7 @@ |
514 | appropriately in bazaar.conf, and your key in the PQM keyring. |
515 | |
516 | Please send feedback to mbp@canonical.com |
517 | -""" |
518 | +""") |
519 | |
520 | #does not currently do anything useful |
521 | """\ |
522 | @@ -80,48 +72,48 @@ |
523 | """ |
524 | |
525 | def show_datetime(label, dt): |
526 | - print " %12s: %s" % (label, dt) |
527 | + print(" %12s: %s" % (label, dt) ) |
528 | # TODO: show relative time |
529 | # (datetime.datetime.utcnow() - dt).days) |
530 | |
531 | |
532 | def show_mp(mp): |
533 | - print mp.web_link |
534 | + print(mp.web_link) |
535 | # nb: .url is empty (except on mirrored branches?) |
536 | - print ' %12s: %s' % ('message', mp.commit_message) |
537 | - print ' %12s: %s' % ('source', mp.source_branch.bzr_identity) |
538 | - print ' %12s: %s' % ('target', mp.target_branch.bzr_identity) |
539 | + print(' %12s: %s' % ('message', mp.commit_message)) |
540 | + print(' %12s: %s' % ('source', mp.source_branch.bzr_identity)) |
541 | + print(' %12s: %s' % ('target', mp.target_branch.bzr_identity)) |
542 | prereq_branch = mp.prerequisite_branch |
543 | if prereq_branch is not None: |
544 | - print ' %12s: %s' % ('prereq', prereq_branch.bzr_identity) |
545 | - print ' %12s: %s' % ('status', mp.queue_status) |
546 | + print(' %12s: %s' % ('prereq', prereq_branch.bzr_identity)) |
547 | + print(' %12s: %s' % ('status', mp.queue_status)) |
548 | show_datetime('created', mp.date_created) |
549 | show_datetime('reviewed', mp.date_reviewed) |
550 | - print ' %12s: %s' % ('registrant', mp.registrant.name) |
551 | + print(' %12s: %s' % ('registrant', mp.registrant.name)) |
552 | for vote in mp.votes_collection: |
553 | # XXX: would like to show the date but see bug 530475 |
554 | - print " %12s: %30s %-12s" % ('vote', vote.reviewer.name, |
555 | + print(" %12s: %30s %-12s" % ('vote', vote.reviewer.name, |
556 | (vote.comment and vote.comment.vote or 'Requested'), |
557 | - ) |
558 | + )) |
559 | # The last comment is usually enough to get a sense for things. Change if |
560 | # desired. |
561 | - print "Recent comments:" |
562 | + print("Recent comments:") |
563 | comments = list(mp.all_comments) #XXX: See bug lp:583761 |
564 | for comment in comments[-1:]: |
565 | val = "%s: %s" % (comment.author.name, comment.message_body) |
566 | try: |
567 | - print val |
568 | + print(val) |
569 | except UnicodeError: |
570 | val = val.encode('ascii', 'replace') |
571 | - print val |
572 | + print(val) |
573 | |
574 | |
575 | def set_message(mp): |
576 | - print "old commit message: %s" % (mp.commit_message,) |
577 | - print "new message> ", |
578 | + print("old commit message: %s" % (mp.commit_message,)) |
579 | + print("new message> ", end='') |
580 | message = raw_input() |
581 | if len(message) < 2: |
582 | - print "Too short to be a commit message?" |
583 | + print("Too short to be a commit message?") |
584 | return |
585 | mp.commit_message = message |
586 | mp.lp_save() |
587 | @@ -129,7 +121,7 @@ |
588 | |
589 | def queue_mp(launchpad, mp): |
590 | if not mp.commit_message: |
591 | - print "No message set? Use 'm'." |
592 | + print("No message set? Use 'm'.") |
593 | return |
594 | if mp.queue_status == 'Queued': |
595 | mp.setStatus(status='Approved') |
596 | @@ -138,22 +130,18 @@ |
597 | |
598 | def send_mp(launchpad, mp, send_mail=True): |
599 | if not mp.commit_message: |
600 | - print "No message set - %s queued badly? Set a message first." % mp |
601 | + print("No message set - %s queued badly? Set a message first." % mp) |
602 | return False |
603 | - print "merge command to be signed:" |
604 | + print("merge command to be signed:") |
605 | raw_message = ( |
606 | "star-merge %s %s\n" |
607 | % (mp.source_branch.composePublicURL(scheme='http'), |
608 | mp.target_branch.composePublicURL(scheme='http'))) |
609 | - print raw_message |
610 | + print(raw_message) |
611 | |
612 | - if bzrlib_version < (2, 5): |
613 | - config = _mod_config.GlobalConfig() |
614 | - my_email = config.user_email() |
615 | - else: |
616 | - config = _mod_config.GlobalStack() |
617 | - my_email = config.get('email') |
618 | - print "Will send email from address <%s>" % (my_email,) |
619 | + config = _mod_config.GlobalStack() |
620 | + my_email = config.get('email') |
621 | + print("Will send email from address <%s>" % (my_email,)) |
622 | signer = gpg.GPGStrategy(config) |
623 | signed_message = signer.sign(raw_message.encode('utf8')) |
624 | # TODO: put in bug numbers as well. |
625 | @@ -163,16 +151,16 @@ |
626 | signed_message) |
627 | if send_mail: |
628 | SMTPConnection(config).send_email(message) |
629 | - print "Sent!" |
630 | + print("Sent!") |
631 | else: |
632 | - print "Not sending email - disabled." |
633 | + print("Not sending email - disabled.") |
634 | |
635 | # suggested subject should match the last comment on the mp so that gmail |
636 | # doesn't see it as a separate thread; |
637 | # <https://bugs.edge.launchpad.net/hydrazine/+bug/541586> |
638 | subject = "Re: [Merge] %s into %s" % (mp.source_branch.bzr_identity, |
639 | mp.target_branch.bzr_identity) |
640 | - print "Recording that the proposal is submitted to PQM." |
641 | + print("Recording that the proposal is submitted to PQM.") |
642 | fed_pqm = "sent to pqm by email\n" |
643 | mp.createComment(content=fed_pqm, subject=subject) |
644 | return True |
645 | @@ -191,7 +179,7 @@ |
646 | find_status = ['Approved'] |
647 | if include_queued: |
648 | find_status.append('Queued') |
649 | - print 'Looking for %r mps in %s' % (find_status, project) |
650 | + print('Looking for %r mps in %s' % (find_status, project)) |
651 | for mp in project.getMergeProposals(status=find_status): |
652 | prereq = mp.prerequisite_branch |
653 | if not prereq or prereq.lifecycle_status == 'Merged': |
654 | @@ -208,7 +196,7 @@ |
655 | parser.print_usage() |
656 | return 1 |
657 | project = args[0] |
658 | - bzrlib_setup() |
659 | + breezy_setup() |
660 | launchpad = hydrazine.create_session() |
661 | project = launchpad.projects[project] |
662 | i = 0 |
663 | @@ -235,7 +223,7 @@ |
664 | elif whatnow == 'm': |
665 | set_message(mp) |
666 | elif whatnow == 's': |
667 | - print "Sorry, not currently implemented %r" % whatnow |
668 | + print("Sorry, not currently implemented %r" % whatnow) |
669 | """ |
670 | queue_mp(launchpad, mp) |
671 | if mp.queue_status not in find_status: |
672 | @@ -253,8 +241,8 @@ |
673 | elif whatnow == '': |
674 | continue |
675 | else: |
676 | - print "Sorry, don't understand %r" % whatnow |
677 | - print "No remaining merge proposals ready to be merged." |
678 | + print("Sorry, don't understand %r" % whatnow) |
679 | + print("No remaining merge proposals ready to be merged.") |
680 | return 0 |
681 | |
682 | if __name__ == '__main__': |
683 | |
684 | === modified file 'lp-attach' |
685 | --- lp-attach 2010-06-30 00:13:48 +0000 |
686 | +++ lp-attach 2021-05-03 12:32:54 +0000 |
687 | @@ -1,4 +1,4 @@ |
688 | -#! /usr/bin/python |
689 | +#! /usr/bin/python3 |
690 | # |
691 | # Copyright (C) 2010 Canonical Ltd |
692 | |
693 | @@ -35,7 +35,7 @@ |
694 | def guess_mime_type(attachment_bytes): |
695 | try: |
696 | import magic |
697 | - except ImportError, e: |
698 | + except ImportError as e: |
699 | sys.stderr.write("can't guess mime-types without the python-magic library: %s" % e) |
700 | mimetype = None |
701 | else: |
702 | @@ -43,13 +43,13 @@ |
703 | mimetype = mime.buffer(attachment_bytes) |
704 | if mimetype is None: |
705 | mimetype = 'application/binary' |
706 | - print 'attachment type %s' % mimetype |
707 | + print('attachment type %s' % mimetype) |
708 | return mimetype |
709 | |
710 | |
711 | def main(argv): |
712 | if len(argv) != 2 or argv[1] == '--help': |
713 | - print __doc__ |
714 | + print(__doc__) |
715 | return 3 |
716 | |
717 | try: |
718 | @@ -59,23 +59,23 @@ |
719 | return 1 |
720 | |
721 | launchpad = hydrazine.create_session() |
722 | - print "getting bug %s" % bugnumber |
723 | + print("getting bug %s" % bugnumber) |
724 | bug = launchpad.bugs[bugnumber] |
725 | - print 'Attaching to %s' % bug |
726 | + print('Attaching to %s' % bug) |
727 | |
728 | attachment_bytes = sys.stdin.read() |
729 | - print '%d bytes to attach' % len(attachment_bytes) |
730 | + print('%d bytes to attach' % len(attachment_bytes)) |
731 | |
732 | mime_type = guess_mime_type(attachment_bytes) |
733 | |
734 | # mime type must be specified otherwise |
735 | # <https://bugs.edge.launchpad.net/malone/+bug/204560> assumes it's |
736 | # chemical/x-mopac-input |
737 | - print bug.addAttachment(comment='', |
738 | + print(bug.addAttachment(comment='', |
739 | data=attachment_bytes, |
740 | description='', |
741 | filename='attachment', |
742 | - content_type=mime_type) |
743 | + content_type=mime_type)) |
744 | |
745 | |
746 | if __name__ == '__main__': |
747 | |
748 | === modified file 'lp-delete-ppa-packages' |
749 | --- lp-delete-ppa-packages 2013-03-23 22:51:00 +0000 |
750 | +++ lp-delete-ppa-packages 2021-05-03 12:32:54 +0000 |
751 | @@ -1,4 +1,4 @@ |
752 | -#!/usr/bin/python |
753 | +#!/usr/bin/python3 |
754 | |
755 | USAGE = """\ |
756 | usage: %prog [options] PPA |
757 | @@ -32,7 +32,7 @@ |
758 | kw['source_name'] = spn |
759 | filter_kwargs.append(kw) |
760 | |
761 | - print "Querying PPA..." |
762 | + print("Querying PPA...") |
763 | archive = lp.people[team].getPPAByName(name=ppa) |
764 | sources = [] |
765 | for kwargs in filter_kwargs: |
766 | @@ -43,7 +43,7 @@ |
767 | version = spph.source_package_version |
768 | series = spph.distro_series_link.split('/')[-1] |
769 | status = spph.status |
770 | - print value, package, series, version, status |
771 | + print(value, package, series, version, status) |
772 | |
773 | if sources and not dry_run: |
774 | sys.stdout.write('Deleting') |
775 | |
776 | === modified file 'lp-promote-ppa' |
777 | --- lp-promote-ppa 2013-03-23 22:49:55 +0000 |
778 | +++ lp-promote-ppa 2021-05-03 12:32:54 +0000 |
779 | @@ -1,4 +1,4 @@ |
780 | -#!/usr/bin/python |
781 | +#!/usr/bin/python3 |
782 | |
783 | USAGE = """\ |
784 | usage: %prog [options] SOURCE-PPA DESTINATION-PPA |
785 | @@ -49,7 +49,7 @@ |
786 | kw['source_name'] = spn |
787 | filter_kwargs.append(kw) |
788 | |
789 | - print "Querying destination PPA..." |
790 | + print("Querying destination PPA...") |
791 | to_archive = lp.people[to_team].getPPAByName(name=to_ppa) |
792 | dest_sources = [] |
793 | for kwargs in filter_kwargs: |
794 | @@ -63,12 +63,12 @@ |
795 | series = spph.distro_series_link.split('/')[-1] |
796 | status = spph.status |
797 | buildstate = buildsumm[value]['status'] |
798 | - print value, package, series, version, status, buildstate |
799 | + print(value, package, series, version, status, buildstate) |
800 | destination_sourcepubs[package, series] = version |
801 | |
802 | |
803 | + print() |
804 | |
805 | - print "Querying source PPA..." |
806 | + print("Querying source PPA...") |
807 | from_archive = lp.people[from_team].getPPAByName(name=from_ppa) |
808 | src_sources = [] |
809 | for kwargs in filter_kwargs: |
810 | @@ -95,16 +95,16 @@ |
811 | note = "*** UPDATED ***" |
812 | elif c < 0: |
813 | note = "*** NEWER IN DESTINATION ***" |
814 | - print value, package, series, version, status, buildstate, note |
815 | + print(value, package, series, version, status, buildstate, note) |
816 | |
817 | if sourcepub_elts: |
818 | |
819 | + print() |
820 | |
821 | for name, version, series in sourcepub_elts: |
822 | if dry_run: |
823 | - print "Would syncSource(%s, %s, %s)" % (name, version, series) |
824 | + print("Would syncSource(%s, %s, %s)" % (name, version, series)) |
825 | else: |
826 | - print "syncSource(%s, %s, %s)..." % (name, version, series) |
827 | + print("syncSource(%s, %s, %s)..." % (name, version, series)) |
828 | to_archive.syncSource(from_archive=from_archive, |
829 | include_binaries=True, source_name=name, |
830 | to_pocket="Release", to_series=series, |
831 | |
832 | === modified file 'scan-merge-proposals' |
833 | --- scan-merge-proposals 2011-04-06 01:30:20 +0000 |
834 | +++ scan-merge-proposals 2021-05-03 12:32:54 +0000 |
835 | @@ -1,4 +1,4 @@ |
836 | -#! /usr/bin/python |
837 | +#! /usr/bin/python3 |
838 | # |
839 | # Copyright (C) 2009 Canonical Ltd |
840 | |
841 | @@ -41,7 +41,7 @@ |
842 | |
843 | def main(argv): |
844 | if len(argv) != 2: |
845 | - print __doc__ |
846 | + print(__doc__) |
847 | return 3 |
848 | |
849 | launchpad = hydrazine.create_session() |
850 | @@ -59,26 +59,26 @@ |
851 | if mp.queue_status not in ['Needs review', |
852 | 'Approved',]: |
853 | continue |
854 | - print mp.web_link |
855 | + print(mp.web_link) |
856 | # registrant is the registrant of the proposed-to-merge branch, ie |
857 | # pretty much the owner of that branch |
858 | registrant_name = mp.registrant.name |
859 | if registrant_name in needs_to_sign: |
860 | - print ' %s already needs to sign' % registrant_name |
861 | + print(' %s already needs to sign' % registrant_name) |
862 | elif registrant_name not in ok_people: |
863 | - print '**** %s not signed up' % registrant_name |
864 | + print('**** %s not signed up' % registrant_name) |
865 | needs_to_sign[registrant_name] = mp.registrant |
866 | else: |
867 | - print '<<<< yay, a member of %s' % ok_people[mp.registrant.name] |
868 | - print ' status %s' % mp.queue_status |
869 | |
870 | + print('<<<< yay, a member of %s' % ok_people[mp.registrant.name]) |
871 | + print(' status %s' % mp.queue_status) |
872 | + print() |
873 | |
874 | if needs_to_sign: |
875 | |
876 | - print 'The following people need to sign the contributor agreement' |
877 | + print() |
878 | + print('The following people need to sign the contributor agreement') |
879 | for person_name, person in sorted(needs_to_sign.items()): |
880 | real_url = person.web_link |
881 | - print '%s <%s>' % (person.display_name, real_url) |
882 | + print('%s <%s>' % (person.display_name, real_url)) |
883 | |
884 | return 0 |
885 | |
886 | |
887 | === modified file 'setup.py' |
888 | --- setup.py 2010-12-02 00:01:31 +0000 |
889 | +++ setup.py 2021-05-03 12:32:54 +0000 |
890 | @@ -1,9 +1,9 @@ |
891 | -#!/usr/bin/python |
892 | +#!/usr/bin/python3 |
893 | |
894 | from distutils.core import setup |
895 | from os.path import join, dirname |
896 | |
897 | -description = file(join(dirname(__file__), 'README'), 'rb').read() |
898 | +description = open(join(dirname(__file__), 'README'), 'r').read() |
899 | |
900 | setup( |
901 | name='hydrazine', |
Hi, sorry for the long delay.
This look fine, thanks for proposing it. I think you are now a co-admin, so feel free to ask me for reviews but also feel free to merge without it.