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

Proposed by William Grant
Status: Merged
Approved by: Tim Penhey
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
Steve Kowalik (community) code* Approve
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.
Revision history for this message
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.

Revision history for this message
Steve Kowalik (stevenk) :
review: Approve (code*)
Revision history for this message
Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/scripts/logger.py'
--- lib/canonical/launchpad/scripts/logger.py 2010-10-22 10:23:17 +0000
+++ lib/canonical/launchpad/scripts/logger.py 2010-12-20 04:50:19 +0000
@@ -428,7 +428,7 @@
428 # Make it print output in a standard format, suitable for428 # Make it print output in a standard format, suitable for
429 # both command line tools and cron jobs (command line tools often end429 # both command line tools and cron jobs (command line tools often end
430 # up being run from inside cron, so this is a good thing).430 # up being run from inside cron, so this is a good thing).
431 hdlr = logging.StreamHandler(strm=out_stream)431 hdlr = logging.StreamHandler(out_stream)
432 # We set the level on the handler rather than the logger, so other432 # We set the level on the handler rather than the logger, so other
433 # handlers with different levels can be added for things like debug433 # handlers with different levels can be added for things like debug
434 # logs.434 # logs.
435435
=== modified file 'lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt'
--- lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt 2010-10-18 22:24:59 +0000
+++ lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt 2010-12-20 04:50:19 +0000
@@ -170,7 +170,8 @@
170170
171== Queue item filelist ==171== Queue item filelist ==
172172
173First set up some additional data: a package diff to show in the listing.173First set up some additional data to show in the listing: a package diff
174and an extra, expired, source file.
174175
175 >>> from zope.security.proxy import removeSecurityProxy176 >>> from zope.security.proxy import removeSecurityProxy
176 >>> from StringIO import StringIO177 >>> from StringIO import StringIO
@@ -190,6 +191,9 @@
190 >>> diff.diff_content = getUtility(ILibrarianClient).addFile(191 >>> diff.diff_content = getUtility(ILibrarianClient).addFile(
191 ... 'alsa-utils.diff.gz', 11, StringIO('i am a diff'),192 ... 'alsa-utils.diff.gz', 11, StringIO('i am a diff'),
192 ... 'application/gzipped-patch')193 ... 'application/gzipped-patch')
194 >>> sprf = new.addFile(factory.makeLibraryFileAlias(
195 ... filename='alsa-utils_1.0.9a-4ubuntu1.diff.gz'))
196 >>> removeSecurityProxy(sprf.libraryfile).content = None
193 >>> logout()197 >>> logout()
194198
195Each queue item has a hidden 'filelist' section which is199Each queue item has a hidden 'filelist' section which is
@@ -212,20 +216,23 @@
212 ... anon_browser.contents, 'queue-4')216 ... anon_browser.contents, 'queue-4')
213217
214It contains a list of files related to the queue item clicked, followed218It contains a list of files related to the queue item clicked, followed
215by its size, one file per line:219by its size, one file per line. Expired files have no size.
216220
217 >>> for row in filelist:221 >>> for row in filelist:
218 ... print extract_text(row)222 ... print extract_text(row)
219 alsa-utils_1.0.9a-4ubuntu1.dsc (3 bytes)223 alsa-utils_1.0.9a-4ubuntu1.dsc (3 bytes)
224 alsa-utils_1.0.9a-4ubuntu1.diff.gz
220 diff from 1.0.9a-4 to 1.0.9a-4ubuntu1 (11 bytes)225 diff from 1.0.9a-4 to 1.0.9a-4ubuntu1 (11 bytes)
221226
222Each filename links to its respective librarian URL:227Each unexpired filename links to its respective librarian URL. Expired
228files have no link, so we just get None.
223229
224 >>> for row in filelist:230 >>> for row in filelist:
225 ... print row.find('a')231 ... print row.find('a')
226 <a href="http://localhost:58000/.../alsa-utils_1.0.9a-4ubuntu1.dsc">232 <a href="http://localhost:58000/.../alsa-utils_1.0.9a-4ubuntu1.dsc">
227 alsa-utils_1.0.9a-4ubuntu1.dsc233 alsa-utils_1.0.9a-4ubuntu1.dsc
228 </a>234 </a>
235 None
229 <a href="http://localhost:58000/.../alsa-utils.diff.gz">diff from 1.0.9a-4 to 1.0.9a-4ubuntu1</a>236 <a href="http://localhost:58000/.../alsa-utils.diff.gz">diff from 1.0.9a-4 to 1.0.9a-4ubuntu1</a>
230237
231On binary queue items we also present the stamp 'NEW' for files never238On binary queue items we also present the stamp 'NEW' for files never
232239
=== modified file 'lib/lp/soyuz/templates/distroseries-queue.pt'
--- lib/lp/soyuz/templates/distroseries-queue.pt 2010-05-13 12:04:56 +0000
+++ lib/lp/soyuz/templates/distroseries-queue.pt 2010-12-20 04:50:19 +0000
@@ -232,11 +232,8 @@
232 style="display:none">232 style="display:none">
233 <td/>233 <td/>
234 <td tal:condition="view/availableActions"/>234 <td tal:condition="view/availableActions"/>
235 <td>235 <td tal:define="libraryfilealias file/libraryfile">
236 <a tal:attributes="href file/libraryfile/http_url">236 <metal:file use-macro="template/macros/package-file"/>
237 <tal:filename content="file/libraryfile/filename"/>
238 </a>
239 (<span tal:replace="file/libraryfile/content/filesize/fmt:bytes" />)
240 </td>237 </td>
241 <td colspan="6"/>238 <td colspan="6"/>
242 </tr>239 </tr>
@@ -252,11 +249,8 @@
252 style="display:none">249 style="display:none">
253 <td/>250 <td/>
254 <td tal:condition="view/availableActions"/>251 <td tal:condition="view/availableActions"/>
255 <td>252 <td tal:define="libraryfilealias file/libraryfile">
256 <a tal:attributes="href file/libraryfile/http_url">253 <metal:file use-macro="template/macros/package-file"/>
257 <tal:filename replace="file/libraryfile/filename"/>
258 </a>
259 (<tal:size replace="file/libraryfile/content/filesize/fmt:bytes" />)
260 <span style="color: red" tal:condition="is_new">NEW</span>254 <span style="color: red" tal:condition="is_new">NEW</span>
261 </td>255 </td>
262 <td tal:content="version"/>256 <td tal:content="version"/>
@@ -274,12 +268,8 @@
274 style="display:none">268 style="display:none">
275 <td/>269 <td/>
276 <td tal:condition="view/availableActions"></td>270 <td tal:condition="view/availableActions"></td>
277 <td>271 <td tal:define="libraryfilealias custom/libraryfilealias">
278 <a tal:attributes="href custom/libraryfilealias/http_url">272 <metal:file use-macro="template/macros/package-file"/>
279 <tal:filename content="custom/libraryfilealias/filename"/>
280 </a>
281 (<tal:size replace="
282 custom/libraryfilealias/content/filesize/fmt:bytes" />)
283 </td>273 </td>
284 <td colspan="6"/>274 <td colspan="6"/>
285 </tr>275 </tr>
@@ -302,6 +292,23 @@
302292
303</metal:macro>293</metal:macro>
304294
295<metal:macro define-macro="package-file">
296 <tal:comment replace="nothing">
297 This macro expects the following variables defined:
298 :libraryfilealias: A LibraryFileAlias to link to. If it is expired,
299 no link will be created.
300 </tal:comment>
301 <tal:unexpired tal:condition="libraryfilealias/content">
302 <a tal:attributes="href libraryfilealias/http_url">
303 <tal:filename replace="libraryfilealias/filename"/>
304 </a>
305 (<span tal:replace="libraryfilealias/content/filesize/fmt:bytes" />)
306 </tal:unexpired>
307 <tal:expired tal:condition="not:libraryfilealias/content">
308 <span tal:content="libraryfilealias/filename"/>
309 </tal:expired>
310</metal:macro>
311
305<metal:macro define-macro="package-iconlist">312<metal:macro define-macro="package-iconlist">
306 <tal:comment replace="nothing">313 <tal:comment replace="nothing">
307 This macro expects the following variables defined:314 This macro expects the following variables defined: