Merge lp:~dholbach/ubuntu-review-overview/simplify into lp:ubuntu-review-overview

Proposed by Daniel Holbach
Status: Superseded
Proposed branch: lp:~dholbach/ubuntu-review-overview/simplify
Merge into: lp:ubuntu-review-overview
Diff against target: 201 lines (+93/-34)
5 files modified
.bzrignore (+2/-0)
clean-sweep.py (+23/-24)
countdown.py (+11/-1)
data.py (+56/-7)
patch-overview.py (+1/-2)
To merge this branch: bzr merge lp:~dholbach/ubuntu-review-overview/simplify
Reviewer Review Type Date Requested Status
Nigel Babu Pending
Review via email: mp+26580@code.launchpad.net

This proposal has been superseded by a proposal from 2010-06-02.

To post a comment you must log in.
25. By Daniel Holbach

add support for old launchpadlib

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2010-06-02 13:09:21 +0000
4@@ -0,0 +1,2 @@
5+bug_list
6+meter.png
7
8=== modified file 'clean-sweep.py'
9--- clean-sweep.py 2010-06-01 15:11:33 +0000
10+++ clean-sweep.py 2010-06-02 13:09:21 +0000
11@@ -11,41 +11,40 @@
12 # team and add the tag patch. Used to subscribe ~ubuntu-reviewers for
13 # clean sweep project.
14
15-from launchpadlib.errors import HTTPError
16-
17-import data,lazr
18-
19-def save_entry(entry):
20- try:
21- entry.lp_save()
22- except HTTPError, error:
23- print error.content
24-
25-launchpad = data.lp_login()
26+import data
27+
28+launchpad = data.lp_login(anonymous=False)
29 # commonly used things
30 ubuntu = launchpad.distributions['ubuntu']
31+reviewers = launchpad.people['ubuntu-reviewers']
32+jfo = launchpad.people['jeremyfoshee']
33
34+bug_list = data.read_bug_list()
35 # excluding needs-packaging since that has a separate process - revu
36 tasks = ubuntu.searchTasks(order_by='-date_last_updated',
37 tags=data.negate_all_tags(['needs-packaging']+data.reviewed_tags),
38 tags_combinator='All', has_patch=True)
39-
40-reviewers = launchpad.people['ubuntu-reviewers']
41-jfo = launchpad.people['jeremyfoshee']
42-
43 for task in tasks:
44 bug = launchpad.bugs[task.bug.id]
45- subscription_people = [a.person for a in bug.subscriptions]
46- subscribers = [a.name for a in filter(lambda a: a.is_valid, subscription_people)]
47+ if bug.id in bug_list or bug.private:
48+ print "Skipping %s" % bug.id
49+ continue
50+ bug_list += [bug.id]
51+ print bug.id
52+ if len(bug_list) % 10:
53+ data.write_bug_list(bug_list)
54
55 # don't act on bugs that already have a sponsor's team subscribed
56+ subscribers = data.get_subscribers(bug)
57 if set(data.workflow_teams).intersection(subscribers):
58 continue
59- try:
60- if task.bug_target_name in data.kernel_packages:
61- bug.subscribe(person=jfo)
62- elif data.skip_packages:
63- continue
64+
65+ if task.bug_target_name in data.kernel_packages and \
66+ not jfo.name in subscribers:
67+ print " - subscribing jfo"
68+ bug.subscribe(person=jfo)
69+ if task.bug_target_name not in data.skip_packages:
70+ print " - subscribing reviewers"
71 bug.subscribe(person=reviewers)
72- except lazr.restfulclient.errors.HTTPError, e:
73- print "Launchpad hates me and LP: #%s %s" % (bug.id,e.response.status)
74+
75+data.write_bug_list(bug_list)
76
77=== modified file 'countdown.py'
78--- countdown.py 2010-05-26 12:13:41 +0000
79+++ countdown.py 2010-06-02 13:09:21 +0000
80@@ -19,8 +19,18 @@
81 for x in range(1,19):
82 for y in range(200 - int(already_reviewed_patches*200 / total_patches), 200):
83 im.putpixel((x,y), (255,0,0))
84- meterfile = os.path.join("meter.png")
85+ meterfile = "meter.png"
86 im.save(meterfile)
87+
88+ print "Total: %s" % total_patches
89+ print "Already reviewed: %s" % already_reviewed_patches
90+ print "In the queue: %s" % (total_patches-already_reviewed_patches)
91+ queue_file = "in-the-queue.txt"
92+ if os.path.exists(queue_file):
93+ os.remove(queue_file)
94+ f = open(queue_file, "w")
95+ f.write("%s\n" % str(total_patches-already_reviewed_patches))
96+ f.close()
97
98 if __name__ == "__main__":
99 try:
100
101=== modified file 'data.py'
102--- data.py 2010-05-31 09:34:12 +0000
103+++ data.py 2010-06-02 13:09:21 +0000
104@@ -14,27 +14,76 @@
105
106 open_status = ['New','Incomplete','Confirmed','Triaged','In Progress', 'Fix Committed']
107
108+bug_list = "bug_list"
109
110 from launchpadlib.launchpad import Launchpad, EDGE_SERVICE_ROOT
111+from launchpadlib.credentials import Credentials
112 from launchpadlib.errors import HTTPError
113
114 import sys
115 import os
116
117-def lp_login():
118+def lp_login(anonymous=True):
119 cachedir = os.path.expanduser("~/.launchpadlib/cache/")
120+ creddir = os.path.expanduser('~/.launchpadlib')
121 if not os.path.exists(cachedir):
122 os.makedirs(cachedir,0700)
123 script_name = sys.argv[0].split("/")[-1].split('.')[0]
124- try:
125- launchpad = Launchpad.login_anonymously(script_name, EDGE_SERVICE_ROOT, cachedir)
126- except HTTPError, e:
127- print >> sys.stderr, 'Error connecting to Launchpad: %s' % str(e)
128- sys.exit(1)
129+ if not anonymous:
130+ if not os.path.isdir(creddir):
131+ os.makedirs(creddir)
132+ cred = os.path.join(creddir, '%s.credentials' % script_name)
133+ if os.path.exists(cred):
134+ credentials = Credentials()
135+ credentials.load(open(cred))
136+ launchpad = Launchpad(credentials, EDGE_SERVICE_ROOT, cachedir)
137+ else:
138+ try:
139+ launchpad = Launchpad.get_token_and_login(script_name, EDGE_SERVICE_ROOT, cachedir)
140+ except HTTPError, e:
141+ raise 'Error connecting to Launchpad: %s' % str(e)
142+ f = open(cred, 'w')
143+ os.chmod(cred, 0600)
144+ launchpad.credentials.save(f)
145+ f.close()
146+ else:
147+ try:
148+ launchpad = Launchpad.login_anonymously(script_name, EDGE_SERVICE_ROOT, cachedir)
149+ except:
150+ # Support for launchpadlib pre 1.5.4.
151+ launchpad = Launchpad.login(script_name, "", "", EDGE_SERVICE_ROOT, cachedir)
152 return launchpad
153
154 def get_count(collection):
155 return int(collection._wadl_resource.representation['total_size'])
156
157 def negate_all_tags(tags):
158- return ",".join(map(lambda a: "-"+a , tags))
159+ return map(lambda a: "-"+a , tags)
160+
161+def is_valid_person(person):
162+ result = False
163+ try:
164+ result = person.is_valid
165+ except HTTPError, e:
166+ print "Problem with '%s': '%s'" % (str(person.self_link), str(e))
167+ return result
168+
169+def get_subscribers(bug):
170+ subscription_people = [a.person for a in bug.subscriptions]
171+ subscribers = [a.name for a in \
172+ filter(lambda a: is_valid_person(a), subscription_people)]
173+ return subscribers
174+
175+def read_bug_list():
176+ if os.path.exists(bug_list):
177+ lines = filter(lambda a: a.strip() != "", open(bug_list).readlines())
178+ return map(lambda a: int(a), lines)
179+ return []
180+
181+def write_bug_list(list_of_bugs):
182+ if os.path.exists(bug_list):
183+ os.remove(bug_list)
184+ f = open(bug_list, "w")
185+ for bug in list_of_bugs:
186+ f.write("%s\n" % str(bug))
187+ f.close()
188
189=== modified file 'patch-overview.py'
190--- patch-overview.py 2010-06-01 15:11:33 +0000
191+++ patch-overview.py 2010-06-02 13:09:21 +0000
192@@ -35,8 +35,7 @@
193
194 for task in tasks:
195 bug = launchpad.bugs[task.bug.id]
196- subscription_people = [a.person for a in bug.subscriptions]
197- subscribers = [a.name for a in filter(lambda a: a.is_valid, subscription_people)]
198+ subscribers = data.get_subscribers(bug)
199
200 # don't act on bugs that already have a sponsor's team subscribed
201 if set(data.workflow_teams).intersection(subscribers):

Subscribers

People subscribed via source and target branches

to all changes: