Merge lp:~brian-murray/ubuntu-archive-tools/queue-tables into lp:ubuntu-archive-tools

Proposed by Brian Murray on 2012-05-30
Status: Rejected
Rejected by: Martin Pitt on 2012-05-31
Proposed branch: lp:~brian-murray/ubuntu-archive-tools/queue-tables
Merge into: lp:ubuntu-archive-tools
Diff against target: 66 lines (+29/-18)
1 file modified
sru-report (+29/-18)
To merge this branch: bzr merge lp:~brian-murray/ubuntu-archive-tools/queue-tables
Reviewer Review Type Date Requested Status
Martin Pitt Needs Fixing on 2012-05-31
Colin Watson 2012-05-30 Approve on 2012-05-31
Review via email: mp+108073@code.launchpad.net

Description of the Change

I converted the get_queue_count function to use the API instead of screen scraping and split the queue table into two parts - one for backports and one for proposed.

To post a comment you must log in.
Colin Watson (cjwatson) wrote :

LGTM. It'd be nice to fix the code duplication introduced by this change at some point, although this script is somewhat replete with duplication already.

review: Approve
Martin Pitt (pitti) wrote :

Please note that I already had some code like this in the past:

http://bazaar.launchpad.net/~ubuntu-archive/ubuntu-archive-tools/trunk/revision/252
http://bazaar.launchpad.net/~ubuntu-archive/ubuntu-archive-tools/trunk/revision/255

but it does not work with the lucid packages used on lillypilly, so I reverted it back then:

http://bazaar.launchpad.net/~ubuntu-archive/ubuntu-archive-tools/trunk/revision/256

Traceback (most recent call last):
  File "ubuntu-archive-tools/sru-report", line 484, in <module>
    main()
  File "ubuntu-archive-tools/sru-report", line 481, in main
    print_report(srus, kernel_ppa)
  File "ubuntu-archive-tools/sru-report", line 218, in print_report
    unapproved_url, get_queue_count('Unapproved', releases[r], 'Proposed'),
  File "ubuntu-archive-tools/sru-report", line 354, in get_queue_count
    pocket=search_pocket))
  File "/usr/lib/pymodules/python2.6/lazr/restfulclient/resource.py", line 717, in __len__
    raise TypeError('collection size is not available')
TypeError: collection size is not available

So I reverted it again for now to keep our reports working. If you find out how to make this work in lucid, we can revisit this.

review: Needs Fixing
Brian Murray (brian-murray) wrote :

This fixes it on Lucid.

+ count = int(release.getPackageUploads(status=search_status,
+ pocket=search_pocket)._wadl_resource.representation['total_size'])

If lillypilly gets updated then we can use len().

Colin Watson (cjwatson) wrote :

Sorry I forgot to mention, but I installed a workaround for this this morning.

I also filed an RT to get lillypilly upgraded.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sru-report'
2--- sru-report 2012-05-04 08:20:11 +0000
3+++ sru-report 2012-05-30 22:31:20 +0000
4@@ -207,17 +207,30 @@
5 lpurl, pkg[1], lpurl+vprop, vprop, lpurl+vsec, vsec))
6 print('</table>')
7
8- print('''<h2><a name="upload-queues">Upload queue status</a></h2>
9-<table>
10- <tr><th>Release</th><th>Unapproved</th><th>New</th></tr>
11-''')
12- for r in releases:
13- new_url = 'https://launchpad.net/ubuntu/%s/+queue?queue_state=0' % r
14- unapproved_url = 'https://launchpad.net/ubuntu/%s/+queue?queue_state=1' % r
15- print(' <tr><td>%s</td><td><a href="%s">%s</a></td><td><a href="%s">%s</a></tr>' % (
16- r,
17- unapproved_url, get_queue_count(unapproved_url),
18- new_url, get_queue_count(new_url)))
19+ print('''<h2><a name="upload-queues">Proposed upload queue status</a></h2>
20+<table>
21+ <tr><th>Release</th><th>Unapproved</th><th>New</th></tr>
22+''')
23+ for r in releases:
24+ new_url = 'https://launchpad.net/ubuntu/%s/+queue?queue_state=0' % r
25+ unapproved_url = 'https://launchpad.net/ubuntu/%s/+queue?queue_state=1' % r
26+ print(' <tr><td>%s</td><td><a href="%s">%s</a></td><td><a href="%s">%s</a></tr>' % (
27+ r,
28+ unapproved_url, get_queue_count('Unapproved', releases[r], 'Proposed'),
29+ new_url, get_queue_count('New', releases[r], 'Proposed')))
30+ print(' </table>')
31+
32+ print('''<h2><a name="upload-queues">Backports upload queue status</a></h2>
33+<table>
34+ <tr><th>Release</th><th>Unapproved</th><th>New</th></tr>
35+''')
36+ for r in releases:
37+ new_url = 'https://launchpad.net/ubuntu/%s/+queue?queue_state=0' % r
38+ unapproved_url = 'https://launchpad.net/ubuntu/%s/+queue?queue_state=1' % r
39+ print(' <tr><td>%s</td><td><a href="%s">%s</a></td><td><a href="%s">%s</a></tr>' % (
40+ r,
41+ unapproved_url, get_queue_count('Unapproved', releases[r], 'Backports'),
42+ new_url, get_queue_count('New', releases[r], 'Backports')))
43 print(' </table>')
44
45 #
46@@ -337,15 +350,13 @@
47
48 queue_page_count_pattern = re.compile('of\s*(\d+)\s*result')
49
50-def get_queue_count(url):
51+def get_queue_count(search_status, release, search_pocket):
52 '''Return number of results of given queue page URL'''
53
54- contents = urlopen(url + '&batch1').read()
55- m = queue_page_count_pattern.search(contents)
56- if m:
57- return str(m.group(1))
58- else:
59- return '0'
60+ count = len(release.getPackageUploads(status=search_status,
61+ pocket=search_pocket))
62+ return count
63+
64
65 def get_srus():
66 '''Generate SRU map.

Subscribers

People subscribed via source and target branches