2
# Simple script that will check which bugs mentioned in NEWS
3
# are not yet marked Fix Released in 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:launchpadlib"
19
options, args = getopt.gnu_getopt(sys.argv, "l", ["launchpad"])
20
options = dict(options)
23
print "Usage: check-newsbugs [--launchpad] NEWS"
25
print "--launchpad Print out Launchpad mail commands for closing bugs "
26
print " that are already fixed."
30
def report_notmarked(bug, task, section):
32
print "Bug %d was mentioned in NEWS but is not marked fix released:" % (bug.id, )
33
print "Launchpad title: %s" % bug.title
34
print "NEWS summary: "
36
if "--launchpad" in options or "-l" in options:
37
print " bug %d" % bug.id
38
print " affects %s" % task.bug_target_name
39
print " status fixreleased"
42
def read_news_bugnos(path):
43
"""Read the bug numbers closed by a particular NEWS file
45
:param path: Path to the NEWS file
46
:return: list of bug numbers that were closed.
48
# Pattern to find bug numbers
49
bug_pattern = re.compile("\#([0-9]+)")
54
for l in f.readlines():
57
parenthesed = section.rsplit("(", 1)[1]
60
# Empty line, next section begins
61
for bugno in [int(m) for m in bug_pattern.findall(parenthesed)]:
62
ret.add((bugno, section))
71
def print_bug_url(bugno):
72
print '<URL:http://pad.lv/%s>' % (bugno,)
74
launchpad = hydrazine.create_session()
75
bugnos = read_news_bugnos(args[1])
76
for bugno, section in bugnos:
78
bug = launchpad.bugs[bugno]
79
except errors.HTTPError, e:
80
if e.response.status == 401:
82
# Private, we can't access the bug content
83
print '%s is private and cannot be accessed' % (bugno,)
89
for task in bug.bug_tasks:
90
parts = task.bug_target_name.split('/')
96
distribution = parts[1]
99
if not fix_released and task.status == "Fix Released":
100
# We could check that the NEWS section and task_status are in
101
# sync, but that would be overkill. (case at hand: bug #416732)
106
print "Bug %d was mentioned in NEWS but is not marked as affecting bzr" % bugno
107
elif not fix_released:
109
report_notmarked(bug, task, section)