/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/check-newsbugs.py

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
# Simple script that will check which bugs mentioned in NEWS 
 
1
#!/usr/bin/python3
 
2
# Simple script that will check which bugs mentioned in NEWS
3
3
# are not yet marked Fix Released in Launchpad
4
4
 
5
5
import getopt, re, sys
7
7
    from launchpadlib.launchpad import Launchpad
8
8
    from lazr.restfulclient import errors
9
9
except ImportError:
10
 
    print "Please install launchpadlib from lp:launchpadlib"
 
10
    print("Please install launchpadlib from lp:launchpadlib")
11
11
    sys.exit(1)
12
12
try:
13
13
    import hydrazine
14
14
except ImportError:
15
 
    print "Please install hydrazine from lp:hydrazine"
 
15
    print("Please install hydrazine from lp:hydrazine")
16
16
    sys.exit(1)
17
17
 
18
18
 
20
20
options = dict(options)
21
21
 
22
22
if len(args) == 1:
23
 
    print ("Usage: check-newsbugs [--launchpad][--webbrowser] "
24
 
           "doc/en/release-notes/bzr-x.y.txt")
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."
 
23
    print("Usage: check-newsbugs [--launchpad][--webbrowser] "
 
24
          "doc/en/release-notes/brz-x.y.txt")
 
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.")
30
30
    sys.exit(1)
31
31
 
32
32
 
33
33
def report_notmarked(bug, task, section):
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
 
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)
39
39
    if "--launchpad" in options or "-l" in options:
40
 
        print "  bug %d" % bug.id
41
 
        print "  affects %s" % task.bug_target_name
42
 
        print "  status fixreleased"
 
40
        print("  bug %d" % bug.id)
 
41
        print("  affects %s" % task.bug_target_name)
 
42
        print("  status fixreleased")
43
43
    if "--webbrowser" in options or "-w" in options:
44
44
        import webbrowser
45
45
        webbrowser.open('http://pad.lv/%s>' % (bug.id,))
52
52
    :return: list of bug numbers that were closed.
53
53
    """
54
54
    # Pattern to find bug numbers
55
 
    bug_pattern = re.compile("\#([0-9]+)")
 
55
    bug_pattern = re.compile(r"\#([0-9]+)")
56
56
    ret = set()
57
 
    f = open(path, 'r')
58
 
    try:
 
57
    with open(path, 'r') as f:
59
58
        section = ""
60
59
        for l in f.readlines():
61
60
            if l.strip() == "":
70
69
            else:
71
70
                section += l
72
71
        return ret
73
 
    finally:
74
 
        f.close()
75
72
 
76
73
 
77
74
def print_bug_url(bugno):
78
 
    print '<URL:http://pad.lv/%s>' % (bugno,)
 
75
    print('<URL:http://pad.lv/%s>' % (bugno,))
79
76
 
80
77
launchpad = hydrazine.create_session()
81
78
bugnos = read_news_bugnos(args[1])
82
79
for bugno, section in bugnos:
83
80
    try:
84
81
        bug = launchpad.bugs[bugno]
85
 
    except errors.HTTPError, e:
 
82
    except errors.HTTPError as e:
86
83
        if e.response.status == 401:
87
84
            print_bug_url(bugno)
88
85
            # Private, we can't access the bug content
89
 
            print '%s is private and cannot be accessed' % (bugno,)
 
86
            print('%s is private and cannot be accessed' % (bugno,))
90
87
            continue
91
88
        raise
92
89
 
93
 
    found_bzr = False
 
90
    found_brz = False
94
91
    fix_released = False
95
92
    for task in bug.bug_tasks:
96
93
        parts = task.bug_target_name.split('/')
100
97
        else:
101
98
            project = parts[0]
102
99
            distribution = parts[1]
103
 
        if project == "bzr":
104
 
            found_bzr = True
 
100
        if project == "brz":
 
101
            found_brz = True
105
102
            if not fix_released and task.status == "Fix Released":
106
103
                # We could check that the NEWS section and task_status are in
107
104
                # sync, but that would be overkill. (case at hand: bug #416732)
108
105
                fix_released = True
109
106
 
110
 
    if not found_bzr:
 
107
    if not found_brz:
111
108
        print_bug_url(bugno)
112
 
        print "Bug %d was mentioned in NEWS but is not marked as affecting bzr" % bugno
 
109
        print("Bug %d was mentioned in NEWS but is not marked as affecting brz" % bugno)
113
110
    elif not fix_released:
114
111
        print_bug_url(bugno)
115
112
        report_notmarked(bug, task, section)