bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
7476.2.1
by Jelmer Vernooij
Default to running Python 3. |
1 |
#!/usr/bin/python3
|
7195.5.1
by Martin
Fix remaining whitespace lint in codebase |
2 |
# Simple script that will check which bugs mentioned in NEWS
|
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
3 |
# are not yet marked Fix Released in Launchpad
|
4 |
||
5 |
import getopt, re, sys |
|
6 |
try: |
|
5274.1.1
by Jelmer Vernooij
Convert check-newsbugs.py to launchpadlib. |
7 |
from launchpadlib.launchpad import Launchpad |
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
8 |
from lazr.restfulclient import errors |
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
9 |
except ImportError: |
6619.3.3
by Jelmer Vernooij
Apply 2to3 print fix. |
10 |
print("Please install launchpadlib from lp:launchpadlib") |
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
11 |
sys.exit(1) |
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
12 |
try: |
13 |
import hydrazine |
|
14 |
except ImportError: |
|
6619.3.3
by Jelmer Vernooij
Apply 2to3 print fix. |
15 |
print("Please install hydrazine from lp:hydrazine") |
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
16 |
sys.exit(1) |
17 |
||
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
18 |
|
5853.4.3
by Vincent Ladeuil
Add an option to check-newsbug to get a quicker access to bugs that needs to be closed. |
19 |
options, args = getopt.gnu_getopt(sys.argv, "lw", ["launchpad", 'webbrowser']) |
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
20 |
options = dict(options) |
21 |
||
22 |
if len(args) == 1: |
|
7143.16.15
by Jelmer Vernooij
Fix E211 |
23 |
print("Usage: check-newsbugs [--launchpad][--webbrowser] " |
24 |
"doc/en/release-notes/brz-x.y.txt") |
|
6619.3.3
by Jelmer Vernooij
Apply 2to3 print fix. |
25 |
print("Options:") |
26 |
print("--launchpad Print out Launchpad mail commands for closing bugs ") |
|
27 |
print(" that are already fixed.") |
|
28 |
print("--webbrowser Open launchpad bug pages for bugs that are already ") |
|
29 |
print(" fixed.") |
|
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
30 |
sys.exit(1) |
31 |
||
32 |
||
33 |
def report_notmarked(bug, task, section): |
|
6619.3.3
by Jelmer Vernooij
Apply 2to3 print fix. |
34 |
print() |
35 |
print("Bug %d was mentioned in NEWS but is not marked fix released:" % (bug.id, )) |
|
36 |
print("Launchpad title: %s" % bug.title) |
|
37 |
print("NEWS summary: ") |
|
38 |
print(section) |
|
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
39 |
if "--launchpad" in options or "-l" in options: |
6619.3.3
by Jelmer Vernooij
Apply 2to3 print fix. |
40 |
print(" bug %d" % bug.id) |
41 |
print(" affects %s" % task.bug_target_name) |
|
42 |
print(" status fixreleased") |
|
5853.4.3
by Vincent Ladeuil
Add an option to check-newsbug to get a quicker access to bugs that needs to be closed. |
43 |
if "--webbrowser" in options or "-w" in options: |
44 |
import webbrowser |
|
45 |
webbrowser.open('http://pad.lv/%s>' % (bug.id,)) |
|
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
46 |
|
47 |
||
48 |
def read_news_bugnos(path): |
|
49 |
"""Read the bug numbers closed by a particular NEWS file |
|
50 |
||
51 |
:param path: Path to the NEWS file
|
|
52 |
:return: list of bug numbers that were closed.
|
|
53 |
"""
|
|
54 |
# Pattern to find bug numbers
|
|
7322.2.1
by Martin
Fix invalid escape sequence warnings in regexps |
55 |
bug_pattern = re.compile(r"\#([0-9]+)") |
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
56 |
ret = set() |
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
57 |
with open(path, 'r') as f: |
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
58 |
section = "" |
59 |
for l in f.readlines(): |
|
60 |
if l.strip() == "": |
|
61 |
try: |
|
62 |
parenthesed = section.rsplit("(", 1)[1] |
|
63 |
except IndexError: |
|
64 |
parenthesed = "" |
|
65 |
# Empty line, next section begins
|
|
66 |
for bugno in [int(m) for m in bug_pattern.findall(parenthesed)]: |
|
67 |
ret.add((bugno, section)) |
|
68 |
section = "" |
|
69 |
else: |
|
70 |
section += l |
|
71 |
return ret |
|
72 |
||
5274.1.1
by Jelmer Vernooij
Convert check-newsbugs.py to launchpadlib. |
73 |
|
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
74 |
def print_bug_url(bugno): |
6619.3.3
by Jelmer Vernooij
Apply 2to3 print fix. |
75 |
print('<URL:http://pad.lv/%s>' % (bugno,)) |
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
76 |
|
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
77 |
launchpad = hydrazine.create_session() |
3966.2.4
by Jelmer Vernooij
Add simple script for checking that all bugs in NEWS are closed in launchpad. |
78 |
bugnos = read_news_bugnos(args[1]) |
79 |
for bugno, section in bugnos: |
|
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
80 |
try: |
81 |
bug = launchpad.bugs[bugno] |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
82 |
except errors.HTTPError as e: |
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
83 |
if e.response.status == 401: |
84 |
print_bug_url(bugno) |
|
85 |
# Private, we can't access the bug content
|
|
6619.3.3
by Jelmer Vernooij
Apply 2to3 print fix. |
86 |
print('%s is private and cannot be accessed' % (bugno,)) |
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
87 |
continue
|
88 |
raise
|
|
5552.1.3
by Vincent Ladeuil
Merge 2.2 into 2.3 including fixes for bug #583667 and bug #681885 |
89 |
|
6622.1.16
by Jelmer Vernooij
s/bzr/brz/ |
90 |
found_brz = False |
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
91 |
fix_released = False |
5274.1.1
by Jelmer Vernooij
Convert check-newsbugs.py to launchpadlib. |
92 |
for task in bug.bug_tasks: |
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
93 |
parts = task.bug_target_name.split('/') |
94 |
if len(parts) == 1: |
|
95 |
project = parts[0] |
|
96 |
distribution = None |
|
97 |
else: |
|
98 |
project = parts[0] |
|
99 |
distribution = parts[1] |
|
6622.1.16
by Jelmer Vernooij
s/bzr/brz/ |
100 |
if project == "brz": |
101 |
found_brz = True |
|
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
102 |
if not fix_released and task.status == "Fix Released": |
103 |
# We could check that the NEWS section and task_status are in
|
|
104 |
# sync, but that would be overkill. (case at hand: bug #416732)
|
|
105 |
fix_released = True |
|
106 |
||
6622.1.16
by Jelmer Vernooij
s/bzr/brz/ |
107 |
if not found_brz: |
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
108 |
print_bug_url(bugno) |
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
109 |
print("Bug %d was mentioned in NEWS but is not marked as affecting brz" % bugno) |
5430.4.1
by Vincent Ladeuil
Tiny doc cleanups and tweaks for tools/check-newsbugs.py. |
110 |
elif not fix_released: |
111 |
print_bug_url(bugno) |
|
112 |
report_notmarked(bug, task, section) |