Merge lp:~wgrant/launchpad/bug-685401-expired-queue-files into lp:launchpad

Proposed by William Grant on 2010-12-20
Status: Merged
Approved by: Tim Penhey on 2010-12-20
Approved revision: no longer in the source branch.
Merged at revision: 12114
Proposed branch: lp:~wgrant/launchpad/bug-685401-expired-queue-files
Merge into: lp:launchpad
Diff against target: 133 lines (+34/-20)
3 files modified
lib/canonical/launchpad/scripts/logger.py (+1/-1)
lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt (+10/-3)
lib/lp/soyuz/templates/distroseries-queue.pt (+23/-16)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-685401-expired-queue-files
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve on 2010-12-20
Steve Kowalik (community) code* 2010-12-20 Approve on 2010-12-20
Review via email: mp+44190@code.launchpad.net

Commit message

[r=stevenk,thumper][ui=none][bug=685401,691844] DistroSeries:+queue no longer crashes when it runs into an expired upload file.

Description of the change

Files related to a PackageUpload can be expired once the upload is processed (translations tarballs are occasionally manually expired, and binaries are expired after a series' obsolescence). DistroSeries:+queue doesn't handle this case, crashing when it attempts to display the file size.

This branch fixes +queue to not link to nor attempt to show the size of expired files. I've slightly augmented an existing doctest to verify this behaviour.

To post a comment you must log in.
William Grant (wgrant) wrote :

Oh, I also threw in a python2.7 fix for canonical.launchpad.scripts.logger. The kwarg was renamed from "strm" to "stream", so I've just made the call positional.

Steve Kowalik (stevenk) :
review: Approve (code*)
Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/scripts/logger.py'
2--- lib/canonical/launchpad/scripts/logger.py 2010-10-22 10:23:17 +0000
3+++ lib/canonical/launchpad/scripts/logger.py 2010-12-20 04:50:19 +0000
4@@ -428,7 +428,7 @@
5 # Make it print output in a standard format, suitable for
6 # both command line tools and cron jobs (command line tools often end
7 # up being run from inside cron, so this is a good thing).
8- hdlr = logging.StreamHandler(strm=out_stream)
9+ hdlr = logging.StreamHandler(out_stream)
10 # We set the level on the handler rather than the logger, so other
11 # handlers with different levels can be added for things like debug
12 # logs.
13
14=== modified file 'lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt'
15--- lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt 2010-10-18 22:24:59 +0000
16+++ lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt 2010-12-20 04:50:19 +0000
17@@ -170,7 +170,8 @@
18
19 == Queue item filelist ==
20
21-First set up some additional data: a package diff to show in the listing.
22+First set up some additional data to show in the listing: a package diff
23+and an extra, expired, source file.
24
25 >>> from zope.security.proxy import removeSecurityProxy
26 >>> from StringIO import StringIO
27@@ -190,6 +191,9 @@
28 >>> diff.diff_content = getUtility(ILibrarianClient).addFile(
29 ... 'alsa-utils.diff.gz', 11, StringIO('i am a diff'),
30 ... 'application/gzipped-patch')
31+ >>> sprf = new.addFile(factory.makeLibraryFileAlias(
32+ ... filename='alsa-utils_1.0.9a-4ubuntu1.diff.gz'))
33+ >>> removeSecurityProxy(sprf.libraryfile).content = None
34 >>> logout()
35
36 Each queue item has a hidden 'filelist' section which is
37@@ -212,20 +216,23 @@
38 ... anon_browser.contents, 'queue-4')
39
40 It contains a list of files related to the queue item clicked, followed
41-by its size, one file per line:
42+by its size, one file per line. Expired files have no size.
43
44 >>> for row in filelist:
45 ... print extract_text(row)
46 alsa-utils_1.0.9a-4ubuntu1.dsc (3 bytes)
47+ alsa-utils_1.0.9a-4ubuntu1.diff.gz
48 diff from 1.0.9a-4 to 1.0.9a-4ubuntu1 (11 bytes)
49
50-Each filename links to its respective librarian URL:
51+Each unexpired filename links to its respective librarian URL. Expired
52+files have no link, so we just get None.
53
54 >>> for row in filelist:
55 ... print row.find('a')
56 <a href="http://localhost:58000/.../alsa-utils_1.0.9a-4ubuntu1.dsc">
57 alsa-utils_1.0.9a-4ubuntu1.dsc
58 </a>
59+ None
60 <a href="http://localhost:58000/.../alsa-utils.diff.gz">diff from 1.0.9a-4 to 1.0.9a-4ubuntu1</a>
61
62 On binary queue items we also present the stamp 'NEW' for files never
63
64=== modified file 'lib/lp/soyuz/templates/distroseries-queue.pt'
65--- lib/lp/soyuz/templates/distroseries-queue.pt 2010-05-13 12:04:56 +0000
66+++ lib/lp/soyuz/templates/distroseries-queue.pt 2010-12-20 04:50:19 +0000
67@@ -232,11 +232,8 @@
68 style="display:none">
69 <td/>
70 <td tal:condition="view/availableActions"/>
71- <td>
72- <a tal:attributes="href file/libraryfile/http_url">
73- <tal:filename content="file/libraryfile/filename"/>
74- </a>
75- (<span tal:replace="file/libraryfile/content/filesize/fmt:bytes" />)
76+ <td tal:define="libraryfilealias file/libraryfile">
77+ <metal:file use-macro="template/macros/package-file"/>
78 </td>
79 <td colspan="6"/>
80 </tr>
81@@ -252,11 +249,8 @@
82 style="display:none">
83 <td/>
84 <td tal:condition="view/availableActions"/>
85- <td>
86- <a tal:attributes="href file/libraryfile/http_url">
87- <tal:filename replace="file/libraryfile/filename"/>
88- </a>
89- (<tal:size replace="file/libraryfile/content/filesize/fmt:bytes" />)
90+ <td tal:define="libraryfilealias file/libraryfile">
91+ <metal:file use-macro="template/macros/package-file"/>
92 <span style="color: red" tal:condition="is_new">NEW</span>
93 </td>
94 <td tal:content="version"/>
95@@ -274,12 +268,8 @@
96 style="display:none">
97 <td/>
98 <td tal:condition="view/availableActions"></td>
99- <td>
100- <a tal:attributes="href custom/libraryfilealias/http_url">
101- <tal:filename content="custom/libraryfilealias/filename"/>
102- </a>
103- (<tal:size replace="
104- custom/libraryfilealias/content/filesize/fmt:bytes" />)
105+ <td tal:define="libraryfilealias custom/libraryfilealias">
106+ <metal:file use-macro="template/macros/package-file"/>
107 </td>
108 <td colspan="6"/>
109 </tr>
110@@ -302,6 +292,23 @@
111
112 </metal:macro>
113
114+<metal:macro define-macro="package-file">
115+ <tal:comment replace="nothing">
116+ This macro expects the following variables defined:
117+ :libraryfilealias: A LibraryFileAlias to link to. If it is expired,
118+ no link will be created.
119+ </tal:comment>
120+ <tal:unexpired tal:condition="libraryfilealias/content">
121+ <a tal:attributes="href libraryfilealias/http_url">
122+ <tal:filename replace="libraryfilealias/filename"/>
123+ </a>
124+ (<span tal:replace="libraryfilealias/content/filesize/fmt:bytes" />)
125+ </tal:unexpired>
126+ <tal:expired tal:condition="not:libraryfilealias/content">
127+ <span tal:content="libraryfilealias/filename"/>
128+ </tal:expired>
129+</metal:macro>
130+
131 <metal:macro define-macro="package-iconlist">
132 <tal:comment replace="nothing">
133 This macro expects the following variables defined: