2
# Simple script that will check which bugs mentioned in NEWS
2
# Simple script that will check which bugs mentioned in NEWS
3
3
# are not yet marked Fix Released in Launchpad
5
5
import getopt, re, sys
7
from launchpadbugs import connector
9
print "Please install launchpadbugs from lp:python-launchpad-bugs"
12
options, args = getopt.gnu_getopt(sys.argv, "l", ["launchpad"])
7
from launchpadlib.launchpad import Launchpad
8
from lazr.restfulclient import errors
10
print("Please install launchpadlib from lp:launchpadlib")
15
print("Please install hydrazine from lp:hydrazine")
19
options, args = getopt.gnu_getopt(sys.argv, "lw", ["launchpad", 'webbrowser'])
13
20
options = dict(options)
16
print "Usage: check-newsbugs [--launchpad] NEWS"
18
print "--launchpad Print out Launchpad mail commands for closing bugs "
19
print " that are already fixed."
23
print("Usage: check-newsbugs [--launchpad][--webbrowser] "
24
"doc/en/release-notes/brz-x.y.txt")
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 ")
23
33
def report_notmarked(bug, task, section):
25
print "Bug %d was mentioned in NEWS but is not marked fix released:" % (bug.bugnumber, )
26
print "Launchpad title: %s" % bug.title
27
print "NEWS summary: "
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: ")
29
39
if "--launchpad" in options or "-l" in options:
30
print " bug %d" % bug.bugnumber
32
print " status fixreleased"
40
print(" bug %d" % bug.id)
41
print(" affects %s" % task.bug_target_name)
42
print(" status fixreleased")
43
if "--webbrowser" in options or "-w" in options:
45
webbrowser.open('http://pad.lv/%s>' % (bug.id,))
35
48
def read_news_bugnos(path):
39
52
:return: list of bug numbers that were closed.
41
54
# Pattern to find bug numbers
42
bug_pattern = re.compile("\#([0-9]+)")
55
bug_pattern = re.compile(r"\#([0-9]+)")
57
with open(path, 'r') as f:
47
59
for l in f.readlines():
48
60
if l.strip() == "":
63
open_bug = connector.ConnectBug("TEXT")
74
def print_bug_url(bugno):
75
print('<URL:http://pad.lv/%s>' % (bugno,))
77
launchpad = hydrazine.create_session()
65
78
bugnos = read_news_bugnos(args[1])
66
79
for bugno, section in bugnos:
67
bug = open_bug(url="https://bugs.launchpad.net/bzr/+bug/%d" % bugno)
69
for task in bug.infotable:
70
if task.affects == "bzr":
72
if task.status != "Fix Released":
73
report_notmarked(bug, task, section)
75
print "Bug %d was mentioned in NEWS but is not marked as affecting bzr" % bugno
81
bug = launchpad.bugs[bugno]
82
except errors.HTTPError as e:
83
if e.response.status == 401:
85
# Private, we can't access the bug content
86
print('%s is private and cannot be accessed' % (bugno,))
92
for task in bug.bug_tasks:
93
parts = task.bug_target_name.split('/')
99
distribution = parts[1]
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)
109
print("Bug %d was mentioned in NEWS but is not marked as affecting brz" % bugno)
110
elif not fix_released:
112
report_notmarked(bug, task, section)