Merge lp:~brian-murray/merge-o-matic/sort-by-age into lp:merge-o-matic
- sort-by-age
- Merge into trunk
Proposed by
Brian Murray
Status: | Merged |
---|---|
Merged at revision: | 245 |
Proposed branch: | lp:~brian-murray/merge-o-matic/sort-by-age |
Merge into: | lp:merge-o-matic |
Diff against target: |
374 lines (+103/-29) 3 files modified
manual-status.py (+27/-13) merge-status.py (+31/-15) momlib.py (+45/-1) |
To merge this branch: | bzr merge lp:~brian-murray/merge-o-matic/sort-by-age |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Core Development Team | Pending | ||
Review via email: mp+264653@code.launchpad.net |
Commit message
To post a comment you must log in.
- 250. By Brian Murray
-
rename set_priority to get_importance, add a docstring for it. rename priority_idx to colour_idx.
- 251. By Brian Murray
-
add bug reference to clarify disabling of updated section
- 252. By Brian Murray
-
remove unused launchpad items, resolve issue with print statement
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'manual-status.py' | |||
2 | --- manual-status.py 2015-07-08 16:40:05 +0000 | |||
3 | +++ manual-status.py 2015-07-14 20:35:53 +0000 | |||
4 | @@ -19,11 +19,12 @@ | |||
5 | 19 | 19 | ||
6 | 20 | from __future__ import print_function, with_statement | 20 | from __future__ import print_function, with_statement |
7 | 21 | 21 | ||
8 | 22 | import bz2 | ||
9 | 22 | import os | 23 | import os |
10 | 23 | import bz2 | ||
11 | 24 | import re | 24 | import re |
12 | 25 | import time | 25 | import time |
13 | 26 | 26 | ||
14 | 27 | from datetime import datetime | ||
15 | 27 | from rfc822 import parseaddr | 28 | from rfc822 import parseaddr |
16 | 28 | from momlib import * | 29 | from momlib import * |
17 | 29 | 30 | ||
18 | @@ -99,7 +100,13 @@ | |||
19 | 99 | except IndexError: | 100 | except IndexError: |
20 | 100 | pass | 101 | pass |
21 | 101 | 102 | ||
23 | 102 | priority_idx = PRIORITY.index(adjusted_priority(our_source)) | 103 | date_superseded = get_date_superseded(source["Package"], |
24 | 104 | base_version) | ||
25 | 105 | if not date_superseded: | ||
26 | 106 | age = datetime.datetime.utcnow() - datetime.datetime.utcnow() | ||
27 | 107 | else: | ||
28 | 108 | age = datetime.datetime.utcnow() - date_superseded.replace(tzinfo=None) | ||
29 | 109 | days_old = age.days | ||
30 | 103 | 110 | ||
31 | 104 | filename = changes_file(our_distro, our_source) | 111 | filename = changes_file(our_distro, our_source) |
32 | 105 | if os.path.isfile(filename): | 112 | if os.path.isfile(filename): |
33 | @@ -114,7 +121,9 @@ | |||
34 | 114 | multi_para=False, signed=False).para | 121 | multi_para=False, signed=False).para |
35 | 115 | 122 | ||
36 | 116 | user = info["Changed-By"] | 123 | user = info["Changed-By"] |
38 | 117 | uploaded = info["Distribution"] == OUR_DIST | 124 | # not enough to determine if it is updated LP: #1474139 |
39 | 125 | # uploaded = info["Distribution"] == OUR_DIST | ||
40 | 126 | uploaded = False | ||
41 | 118 | else: | 127 | else: |
42 | 119 | user = None | 128 | user = None |
43 | 120 | uploaded = False | 129 | uploaded = False |
44 | @@ -126,7 +135,7 @@ | |||
45 | 126 | else: | 135 | else: |
46 | 127 | section = "new" | 136 | section = "new" |
47 | 128 | 137 | ||
49 | 129 | merges.append((section, priority_idx, package, user, uploader, | 138 | merges.append((section, days_old, package, user, uploader, |
50 | 130 | our_source, our_version, src_version)) | 139 | our_source, our_version, src_version)) |
51 | 131 | 140 | ||
52 | 132 | write_status_page(our_component, merges, our_distro, src_distro) | 141 | write_status_page(our_component, merges, our_distro, src_distro) |
53 | @@ -139,7 +148,7 @@ | |||
54 | 139 | 148 | ||
55 | 140 | def write_status_page(component, merges, left_distro, right_distro): | 149 | def write_status_page(component, merges, left_distro, right_distro): |
56 | 141 | """Write out the manual merge status page.""" | 150 | """Write out the manual merge status page.""" |
58 | 142 | merges.sort() | 151 | merges.sort(reverse=True) |
59 | 143 | 152 | ||
60 | 144 | status_file = "%s/merges/%s-manual.html" % (ROOT, component) | 153 | status_file = "%s/merges/%s-manual.html" % (ROOT, component) |
61 | 145 | with open(status_file + ".new", "w") as status: | 154 | with open(status_file + ".new", "w") as status: |
62 | @@ -235,14 +244,16 @@ | |||
63 | 235 | print("<td colspan=2><b>Last Uploader</b></td>", file=status) | 244 | print("<td colspan=2><b>Last Uploader</b></td>", file=status) |
64 | 236 | print("<td rowspan=2><b>Comment</b></td>", file=status) | 245 | print("<td rowspan=2><b>Comment</b></td>", file=status) |
65 | 237 | print("<td rowspan=2><b>Bug</b></td>", file=status) | 246 | print("<td rowspan=2><b>Bug</b></td>", file=status) |
66 | 247 | print("<td rowspan=2><b>Days Old</b></td>", file=status) | ||
67 | 238 | print("</tr>", file=status) | 248 | print("</tr>", file=status) |
68 | 239 | print("<tr bgcolor=#d0d0d0>", file=status) | 249 | print("<tr bgcolor=#d0d0d0>", file=status) |
69 | 240 | print("<td><b>%s Version</b></td>" % left_distro.title(), file=status) | 250 | print("<td><b>%s Version</b></td>" % left_distro.title(), file=status) |
70 | 241 | print("<td><b>%s Version</b></td>" % right_distro.title(), file=status) | 251 | print("<td><b>%s Version</b></td>" % right_distro.title(), file=status) |
71 | 242 | print("</tr>", file=status) | 252 | print("</tr>", file=status) |
72 | 243 | 253 | ||
74 | 244 | for uploaded, priority, package, user, uploader, source, \ | 254 | for uploaded, age, package, user, uploader, source, \ |
75 | 245 | left_version, right_version in merges: | 255 | left_version, right_version in merges: |
76 | 256 | colour_idx = get_importance(age) | ||
77 | 246 | if user is not None: | 257 | if user is not None: |
78 | 247 | (usr_name, usr_mail) = parseaddr(user) | 258 | (usr_name, usr_mail) = parseaddr(user) |
79 | 248 | user_lp_page = get_person_lp_page(usr_mail) | 259 | user_lp_page = get_person_lp_page(usr_mail) |
80 | @@ -272,7 +283,7 @@ | |||
81 | 272 | else: | 283 | else: |
82 | 273 | who = " " | 284 | who = " " |
83 | 274 | 285 | ||
85 | 275 | print("<tr bgcolor=%s class=first>" % COLOURS[priority], file=status) | 286 | print("<tr bgcolor=%s class=first>" % COLOURS[colour_idx], file=status) |
86 | 276 | print("<td><tt><a href=\"https://patches.ubuntu.com/" \ | 287 | print("<td><tt><a href=\"https://patches.ubuntu.com/" \ |
87 | 277 | "%s/%s/%s_%s.patch\">%s</a></tt>" \ | 288 | "%s/%s/%s_%s.patch\">%s</a></tt>" \ |
88 | 278 | % (pathhash(package), package, package, left_version, package), | 289 | % (pathhash(package), package, package, left_version, package), |
89 | @@ -293,7 +304,7 @@ | |||
90 | 293 | if \"%s\" in comment:\n\ | 304 | if \"%s\" in comment:\n\ |
91 | 294 | the_comment = comment[\"%s\"]\n\ | 305 | the_comment = comment[\"%s\"]\n\ |
92 | 295 | req.write(\"<input type=\\\"text\\\" style=\\\"border-style: none; background-color: %s\\\" name=\\\"comment\\\" value=\\\"%%s\\\" title=\\\"%%s\\\" />\" %% (the_comment, the_comment))\n\ | 306 | req.write(\"<input type=\\\"text\\\" style=\\\"border-style: none; background-color: %s\\\" name=\\\"comment\\\" value=\\\"%%s\\\" title=\\\"%%s\\\" />\" %% (the_comment, the_comment))\n\ |
94 | 296 | %%>" % (package, package, COLOURS[priority]), file=status) | 307 | %%>" % (package, package, COLOURS[colour_idx]), file=status) |
95 | 297 | print("</form></td>", file=status) | 308 | print("</form></td>", file=status) |
96 | 298 | print("<td rowspan=2>", file=status) | 309 | print("<td rowspan=2>", file=status) |
97 | 299 | print("<%%\n\ | 310 | print("<%%\n\ |
98 | @@ -304,8 +315,11 @@ | |||
99 | 304 | \n\ | 315 | \n\ |
100 | 305 | %%>" % (package, package), file=status) | 316 | %%>" % (package, package), file=status) |
101 | 306 | print("</td>", file=status) | 317 | print("</td>", file=status) |
102 | 318 | print("<td rowspan=2>", file=status) | ||
103 | 319 | print("%s" % age, file=status) | ||
104 | 320 | print("</td>", file=status) | ||
105 | 307 | print("</tr>", file=status) | 321 | print("</tr>", file=status) |
107 | 308 | print("<tr bgcolor=%s>" % COLOURS[priority], file=status) | 322 | print("<tr bgcolor=%s>" % COLOURS[colour_idx], file=status) |
108 | 309 | print("<td><small>%s</small></td>" % source["Binary"], file=status) | 323 | print("<td><small>%s</small></td>" % source["Binary"], file=status) |
109 | 310 | print("<td>%s</td>" % left_version, file=status) | 324 | print("<td>%s</td>" % left_version, file=status) |
110 | 311 | print("<td>%s</td>" % right_version, file=status) | 325 | print("<td>%s</td>" % right_version, file=status) |
111 | @@ -322,7 +336,7 @@ | |||
112 | 322 | # not that hard to do it ourselves. | 336 | # not that hard to do it ourselves. |
113 | 323 | print('[', file=status) | 337 | print('[', file=status) |
114 | 324 | cur_merge = 0 | 338 | cur_merge = 0 |
116 | 325 | for uploaded, priority, package, user, uploader, source, \ | 339 | for uploaded, age, package, user, uploader, source, \ |
117 | 326 | left_version, right_version in merges: | 340 | left_version, right_version in merges: |
118 | 327 | print(' {', end=' ', file=status) | 341 | print(' {', end=' ', file=status) |
119 | 328 | # source_package, short_description, and link are for | 342 | # source_package, short_description, and link are for |
120 | @@ -333,7 +347,7 @@ | |||
121 | 333 | print('"link": "https://merges.ubuntu.com/%s/%s/",' % | 347 | print('"link": "https://merges.ubuntu.com/%s/%s/",' % |
122 | 334 | (pathhash(package), package), end=' ', file=status) | 348 | (pathhash(package), package), end=' ', file=status) |
123 | 335 | print('"uploaded": "%s",' % uploaded, end=' ', file=status) | 349 | print('"uploaded": "%s",' % uploaded, end=' ', file=status) |
125 | 336 | print('"priority": "%s",' % priority, end=' ', file=status) | 350 | print('"age": "%s",' % age, end=' ', file=status) |
126 | 337 | if user is not None: | 351 | if user is not None: |
127 | 338 | who = user | 352 | who = user |
128 | 339 | who = who.replace('\\', '\\\\') | 353 | who = who.replace('\\', '\\\\') |
129 | @@ -367,10 +381,10 @@ | |||
130 | 367 | def write_status_file(status_file, merges): | 381 | def write_status_file(status_file, merges): |
131 | 368 | """Write out the merge status file.""" | 382 | """Write out the merge status file.""" |
132 | 369 | with open(status_file + ".new", "w") as status: | 383 | with open(status_file + ".new", "w") as status: |
134 | 370 | for uploaded, priority, package, user, uploader, source, \ | 384 | for uploaded, age, package, user, uploader, source, \ |
135 | 371 | left_version, right_version in merges: | 385 | left_version, right_version in merges: |
136 | 372 | print("%s %s %s %s, %s, %s, %s" | 386 | print("%s %s %s %s, %s, %s, %s" |
138 | 373 | % (package, priority, | 387 | % (package, age, |
139 | 374 | left_version, right_version, user, uploader, uploaded), | 388 | left_version, right_version, user, uploader, uploaded), |
140 | 375 | file=status) | 389 | file=status) |
141 | 376 | 390 | ||
142 | 377 | 391 | ||
143 | === modified file 'merge-status.py' | |||
144 | --- merge-status.py 2015-07-08 16:40:05 +0000 | |||
145 | +++ merge-status.py 2015-07-14 20:35:53 +0000 | |||
146 | @@ -19,11 +19,12 @@ | |||
147 | 19 | 19 | ||
148 | 20 | from __future__ import print_function, with_statement | 20 | from __future__ import print_function, with_statement |
149 | 21 | 21 | ||
150 | 22 | import bz2 | ||
151 | 22 | import os | 23 | import os |
152 | 23 | import bz2 | ||
153 | 24 | import re | 24 | import re |
154 | 25 | import time | 25 | import time |
155 | 26 | 26 | ||
156 | 27 | from datetime import datetime | ||
157 | 27 | from rfc822 import parseaddr | 28 | from rfc822 import parseaddr |
158 | 28 | from momlib import * | 29 | from momlib import * |
159 | 29 | 30 | ||
160 | @@ -90,8 +91,13 @@ | |||
161 | 90 | our_distro, src_distro) | 91 | our_distro, src_distro) |
162 | 91 | except ValueError: | 92 | except ValueError: |
163 | 92 | continue | 93 | continue |
166 | 93 | 94 | date_superseded = get_date_superseded(source["Package"], | |
167 | 94 | priority_idx = PRIORITY.index(adjusted_priority(source)) | 95 | base_version) |
168 | 96 | if not date_superseded: | ||
169 | 97 | age = datetime.datetime.utcnow() - datetime.datetime.utcnow() | ||
170 | 98 | else: | ||
171 | 99 | age = datetime.datetime.utcnow() - date_superseded.replace(tzinfo=None) | ||
172 | 100 | days_old = age.days | ||
173 | 95 | 101 | ||
174 | 96 | filename = changes_file(our_distro, source) | 102 | filename = changes_file(our_distro, source) |
175 | 97 | if os.path.isfile(filename): | 103 | if os.path.isfile(filename): |
176 | @@ -110,7 +116,13 @@ | |||
177 | 110 | except KeyError: | 116 | except KeyError: |
178 | 111 | user = None | 117 | user = None |
179 | 112 | try: | 118 | try: |
181 | 113 | uploaded = info["Distribution"] == OUR_DIST | 119 | uploaded = False |
182 | 120 | # not enough to determine if it is updated LP: #1474139 | ||
183 | 121 | # uploaded = info["Distribution"] == OUR_DIST | ||
184 | 122 | # better but not sufficient | ||
185 | 123 | # if info["Distribution"] == OUR_DIST: | ||
186 | 124 | # if base_version.upstream == left_version.upstream: | ||
187 | 125 | # uploaded = True | ||
188 | 114 | except KeyError: | 126 | except KeyError: |
189 | 115 | uploaded = False | 127 | uploaded = False |
190 | 116 | else: | 128 | else: |
191 | @@ -128,11 +140,10 @@ | |||
192 | 128 | else: | 140 | else: |
193 | 129 | section = "new" | 141 | section = "new" |
194 | 130 | 142 | ||
196 | 131 | merges.append((section, priority_idx, source["Package"], user, | 143 | merges.append((section, days_old, source["Package"], user, |
197 | 132 | uploader, source, base_version, | 144 | uploader, source, base_version, |
198 | 133 | left_version, right_version)) | 145 | left_version, right_version)) |
201 | 134 | 146 | merges.sort(reverse=True) | |
200 | 135 | merges.sort() | ||
202 | 136 | 147 | ||
203 | 137 | write_status_page(our_component, merges, our_distro, src_distro) | 148 | write_status_page(our_component, merges, our_distro, src_distro) |
204 | 138 | write_status_json(our_component, merges, our_distro, src_distro) | 149 | write_status_json(our_component, merges, our_distro, src_distro) |
205 | @@ -256,6 +267,7 @@ | |||
206 | 256 | print("<td colspan=3><b>Last Uploader</b></td>", file=status) | 267 | print("<td colspan=3><b>Last Uploader</b></td>", file=status) |
207 | 257 | print("<td rowspan=2><b>Comment</b></td>", file=status) | 268 | print("<td rowspan=2><b>Comment</b></td>", file=status) |
208 | 258 | print("<td rowspan=2><b>Bug</b></td>", file=status) | 269 | print("<td rowspan=2><b>Bug</b></td>", file=status) |
209 | 270 | print("<td rowspan=2><b>Days Old</b></td>", file=status) | ||
210 | 259 | print("</tr>", file=status) | 271 | print("</tr>", file=status) |
211 | 260 | print("<tr bgcolor=#d0d0d0>", file=status) | 272 | print("<tr bgcolor=#d0d0d0>", file=status) |
212 | 261 | print("<td><b>%s Version</b></td>" % left_distro.title(), file=status) | 273 | print("<td><b>%s Version</b></td>" % left_distro.title(), file=status) |
213 | @@ -263,8 +275,9 @@ | |||
214 | 263 | print("<td><b>Base Version</b></td>", file=status) | 275 | print("<td><b>Base Version</b></td>", file=status) |
215 | 264 | print("</tr>", file=status) | 276 | print("</tr>", file=status) |
216 | 265 | 277 | ||
218 | 266 | for uploaded, priority, package, user, uploader, source, \ | 278 | for uploaded, age, package, user, uploader, source, \ |
219 | 267 | base_version, left_version, right_version in merges: | 279 | base_version, left_version, right_version in merges: |
220 | 280 | colour_idx = get_importance(age) | ||
221 | 268 | if user is not None: | 281 | if user is not None: |
222 | 269 | (usr_name, usr_mail) = parseaddr(user) | 282 | (usr_name, usr_mail) = parseaddr(user) |
223 | 270 | user_lp_page = get_person_lp_page(usr_mail) | 283 | user_lp_page = get_person_lp_page(usr_mail) |
224 | @@ -294,7 +307,7 @@ | |||
225 | 294 | else: | 307 | else: |
226 | 295 | who = " " | 308 | who = " " |
227 | 296 | 309 | ||
229 | 297 | print("<tr bgcolor=%s class=first>" % COLOURS[priority], file=status) | 310 | print("<tr bgcolor=%s class=first>" % COLOURS[colour_idx], file=status) |
230 | 298 | print("<td><tt><a href=\"%s/%s/REPORT\">" \ | 311 | print("<td><tt><a href=\"%s/%s/REPORT\">" \ |
231 | 299 | "%s</a></tt>" % (pathhash(package), package, package), | 312 | "%s</a></tt>" % (pathhash(package), package, package), |
232 | 300 | file=status) | 313 | file=status) |
233 | @@ -311,7 +324,7 @@ | |||
234 | 311 | if \"%s\" in comment:\n\ | 324 | if \"%s\" in comment:\n\ |
235 | 312 | the_comment = comment[\"%s\"]\n\ | 325 | the_comment = comment[\"%s\"]\n\ |
236 | 313 | req.write(\"<input type=\\\"text\\\" style=\\\"border-style: none; background-color: %s\\\" name=\\\"comment\\\" value=\\\"%%s\\\" title=\\\"%%s\\\" />\" %% (the_comment, the_comment))\n\ | 326 | req.write(\"<input type=\\\"text\\\" style=\\\"border-style: none; background-color: %s\\\" name=\\\"comment\\\" value=\\\"%%s\\\" title=\\\"%%s\\\" />\" %% (the_comment, the_comment))\n\ |
238 | 314 | %%>" % (package, package, COLOURS[priority]), file=status) | 327 | %%>" % (package, package, COLOURS[colour_idx]), file=status) |
239 | 315 | print("</form></td>", file=status) | 328 | print("</form></td>", file=status) |
240 | 316 | print("<td rowspan=2>", file=status) | 329 | print("<td rowspan=2>", file=status) |
241 | 317 | print("<%%\n\ | 330 | print("<%%\n\ |
242 | @@ -322,8 +335,11 @@ | |||
243 | 322 | \n\ | 335 | \n\ |
244 | 323 | %%>" % (package, package), file=status) | 336 | %%>" % (package, package), file=status) |
245 | 324 | print("</td>", file=status) | 337 | print("</td>", file=status) |
246 | 338 | print("<td rowspan=2>", file=status) | ||
247 | 339 | print("%s" % age, file=status) | ||
248 | 340 | print("</td>", file=status) | ||
249 | 325 | print("</tr>", file=status) | 341 | print("</tr>", file=status) |
251 | 326 | print("<tr bgcolor=%s>" % COLOURS[priority], file=status) | 342 | print("<tr bgcolor=%s>" % COLOURS[colour_idx], file=status) |
252 | 327 | print("<td><small>%s</small></td>" % source["Binary"], file=status) | 343 | print("<td><small>%s</small></td>" % source["Binary"], file=status) |
253 | 328 | print("<td>%s</td>" % left_version, file=status) | 344 | print("<td>%s</td>" % left_version, file=status) |
254 | 329 | print("<td>%s</td>" % right_version, file=status) | 345 | print("<td>%s</td>" % right_version, file=status) |
255 | @@ -341,7 +357,7 @@ | |||
256 | 341 | # not that hard to do it ourselves. | 357 | # not that hard to do it ourselves. |
257 | 342 | print('[', file=status) | 358 | print('[', file=status) |
258 | 343 | cur_merge = 0 | 359 | cur_merge = 0 |
260 | 344 | for uploaded, priority, package, user, uploader, source, \ | 360 | for uploaded, age, package, user, uploader, source, \ |
261 | 345 | base_version, left_version, right_version in merges: | 361 | base_version, left_version, right_version in merges: |
262 | 346 | print(' {', end=' ', file=status) | 362 | print(' {', end=' ', file=status) |
263 | 347 | # source_package, short_description, and link are for | 363 | # source_package, short_description, and link are for |
264 | @@ -352,7 +368,7 @@ | |||
265 | 352 | print('"link": "https://merges.ubuntu.com/%s/%s/",' % | 368 | print('"link": "https://merges.ubuntu.com/%s/%s/",' % |
266 | 353 | (pathhash(package), package), end=' ', file=status) | 369 | (pathhash(package), package), end=' ', file=status) |
267 | 354 | print('"uploaded": "%s",' % uploaded, end=' ', file=status) | 370 | print('"uploaded": "%s",' % uploaded, end=' ', file=status) |
269 | 355 | print('"priority": "%s",' % priority, end=' ', file=status) | 371 | print('"age": "%s",' % age, end=' ', file=status) |
270 | 356 | if user is not None: | 372 | if user is not None: |
271 | 357 | who = user | 373 | who = user |
272 | 358 | who = who.replace('\\', '\\\\') | 374 | who = who.replace('\\', '\\\\') |
273 | @@ -387,10 +403,10 @@ | |||
274 | 387 | def write_status_file(status_file, merges): | 403 | def write_status_file(status_file, merges): |
275 | 388 | """Write out the merge status file.""" | 404 | """Write out the merge status file.""" |
276 | 389 | with open(status_file + ".new", "w") as status: | 405 | with open(status_file + ".new", "w") as status: |
278 | 390 | for uploaded, priority, package, user, uploader, source, \ | 406 | for uploaded, age, package, user, uploader, source, \ |
279 | 391 | base_version, left_version, right_version in merges: | 407 | base_version, left_version, right_version in merges: |
280 | 392 | print("%s %s %s %s %s %s, %s, %s" | 408 | print("%s %s %s %s %s %s, %s, %s" |
282 | 393 | % (package, priority, base_version, | 409 | % (package, age, base_version, |
283 | 394 | left_version, right_version, user, uploader, uploaded), | 410 | left_version, right_version, user, uploader, uploaded), |
284 | 395 | file=status) | 411 | file=status) |
285 | 396 | 412 | ||
286 | 397 | 413 | ||
287 | === modified file 'momlib.py' | |||
288 | --- momlib.py 2015-07-08 16:40:05 +0000 | |||
289 | +++ momlib.py 2015-07-14 20:35:53 +0000 | |||
290 | @@ -4,6 +4,7 @@ | |||
291 | 4 | # | 4 | # |
292 | 5 | # Copyright © 2008 Canonical Ltd. | 5 | # Copyright © 2008 Canonical Ltd. |
293 | 6 | # Author: Scott James Remnant <scott@ubuntu.com>. | 6 | # Author: Scott James Remnant <scott@ubuntu.com>. |
294 | 7 | # Brian Murray <brian@ubuntu.com> | ||
295 | 7 | # | 8 | # |
296 | 8 | # This program is free software: you can redistribute it and/or modify | 9 | # This program is free software: you can redistribute it and/or modify |
297 | 9 | # it under the terms of version 3 of the GNU General Public License as | 10 | # it under the terms of version 3 of the GNU General Public License as |
298 | @@ -36,6 +37,7 @@ | |||
299 | 36 | import json | 37 | import json |
300 | 37 | 38 | ||
301 | 38 | from cgi import escape | 39 | from cgi import escape |
302 | 40 | from launchpadlib.launchpad import Launchpad | ||
303 | 39 | from optparse import OptionParser | 41 | from optparse import OptionParser |
304 | 40 | from urllib import quote | 42 | from urllib import quote |
305 | 41 | from urllib2 import urlopen | 43 | from urllib2 import urlopen |
306 | @@ -113,6 +115,9 @@ | |||
307 | 113 | # mapping of uploader emails to Launchpad pages | 115 | # mapping of uploader emails to Launchpad pages |
308 | 114 | person_lp_page_mapping = {} | 116 | person_lp_page_mapping = {} |
309 | 115 | 117 | ||
310 | 118 | # Launchpad connection | ||
311 | 119 | LAUNCHPAD = Launchpad.login_anonymously('merge-o-matic', 'production', | ||
312 | 120 | '/tmp/lplib-cache') | ||
313 | 116 | 121 | ||
314 | 117 | # --------------------------------------------------------------------------- # | 122 | # --------------------------------------------------------------------------- # |
315 | 118 | # Command-line tool functions | 123 | # Command-line tool functions |
316 | @@ -196,6 +201,19 @@ | |||
317 | 196 | person_lp_page_mapping[person_email] = data[0]["web_link"] | 201 | person_lp_page_mapping[person_email] = data[0]["web_link"] |
318 | 197 | return person_lp_page_mapping[person_email] | 202 | return person_lp_page_mapping[person_email] |
319 | 198 | 203 | ||
320 | 204 | def get_importance(days): | ||
321 | 205 | "Return an int representing the importance of an item." | ||
322 | 206 | if days <= 30: | ||
323 | 207 | return 5 | ||
324 | 208 | elif days <= 60: | ||
325 | 209 | return 4 | ||
326 | 210 | elif days <= 90: | ||
327 | 211 | return 3 | ||
328 | 212 | elif days <= 180: | ||
329 | 213 | return 2 | ||
330 | 214 | elif days <= 365: | ||
331 | 215 | return 1 | ||
332 | 216 | return 0 | ||
333 | 199 | 217 | ||
334 | 200 | # --------------------------------------------------------------------------- # | 218 | # --------------------------------------------------------------------------- # |
335 | 201 | # Location functions | 219 | # Location functions |
336 | @@ -731,7 +749,7 @@ | |||
337 | 731 | 749 | ||
338 | 732 | def get_comments(): | 750 | def get_comments(): |
339 | 733 | """Extract the comments from file, and return a dictionary | 751 | """Extract the comments from file, and return a dictionary |
341 | 734 | containing comments corresponding to packages""" | 752 | containing comments corresponding to packages""" |
342 | 735 | comments = {} | 753 | comments = {} |
343 | 736 | 754 | ||
344 | 737 | with open(comments_file(), "r") as file_comments: | 755 | with open(comments_file(), "r") as file_comments: |
345 | @@ -796,3 +814,29 @@ | |||
346 | 796 | html += " " | 814 | html += " " |
347 | 797 | 815 | ||
348 | 798 | return html | 816 | return html |
349 | 817 | |||
350 | 818 | # --------------------------------------------------------------------------- # | ||
351 | 819 | # Launchpadlib functions | ||
352 | 820 | # --------------------------------------------------------------------------- # | ||
353 | 821 | def get_date_superseded(package, base_version): | ||
354 | 822 | from debian.debian_support import Version | ||
355 | 823 | base_version = Version(base_version) | ||
356 | 824 | |||
357 | 825 | src_distro = LAUNCHPAD.projects[SRC_DISTRO] | ||
358 | 826 | src_archive = src_distro.main_archive | ||
359 | 827 | |||
360 | 828 | date_superseded = None | ||
361 | 829 | ver_superseded = None | ||
362 | 830 | for spph in src_archive.getPublishedSources(source_name=package, | ||
363 | 831 | exact_match=True, | ||
364 | 832 | pocket='Release'): | ||
365 | 833 | version = Version(spph.source_package_version) | ||
366 | 834 | if version <= base_version: | ||
367 | 835 | break | ||
368 | 836 | date_superseded = spph.date_created | ||
369 | 837 | ver_superseded = version | ||
370 | 838 | else: | ||
371 | 839 | if False: | ||
372 | 840 | print("Base version %s of %s never published in Debian." % | ||
373 | 841 | (base_version, package)) | ||
374 | 842 | return date_superseded |