Merge lp:~cjohnston/launchpad-work-items-tracker/no-crash-on-404 into lp:launchpad-work-items-tracker

Proposed by Chris Johnston
Status: Merged
Approved by: Martin Pitt
Approved revision: 310
Merged at revision: 311
Proposed branch: lp:~cjohnston/launchpad-work-items-tracker/no-crash-on-404
Merge into: lp:launchpad-work-items-tracker
Diff against target: 36 lines (+10/-2)
1 file modified
lpworkitems/collect.py (+10/-2)
To merge this branch: bzr merge lp:~cjohnston/launchpad-work-items-tracker/no-crash-on-404
Reviewer Review Type Date Requested Status
Martin Pitt (community) Approve
Review via email: mp+143913@code.launchpad.net

Description of the change

The collect script will error and give a traceback when a 404 is received from the LP API. This allow the script to continue after getting a 404.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

This is a crash that "Should Not Happen"™. Can you find out the URL that crashes and report a bug against Launchpad for this?

As a workaround this looks good to me, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lpworkitems/collect.py'
--- lpworkitems/collect.py 2011-12-06 15:20:43 +0000
+++ lpworkitems/collect.py 2013-01-18 16:49:21 +0000
@@ -1,6 +1,8 @@
1import datetime1import datetime
2import urllib2import urllib
33
4from lazr.restfulclient.errors import NotFound
5
4from lpworkitems import models6from lpworkitems import models
5from lpworkitems.error_collector import MilestoneError7from lpworkitems.error_collector import MilestoneError
68
@@ -313,7 +315,10 @@
313315
314 def get_workitem_if_tracked(self, task, projects=None,316 def get_workitem_if_tracked(self, task, projects=None,
315 distro_release=None):317 distro_release=None):
316 target = self.lp.load(task.target.self_link)318 try:
319 target = self.lp.load(task.target.self_link)
320 except NotFound:
321 return None
317 def get_rtype(obj):322 def get_rtype(obj):
318 return urllib.splittag(obj.resource_type_link)[1]323 return urllib.splittag(obj.resource_type_link)[1]
319 rtype = get_rtype(target)324 rtype = get_rtype(target)
@@ -353,7 +358,10 @@
353 return None358 return None
354 if rtype == self.DISTRIBUTION_SOURCE_PACKAGE_RTYPE:359 if rtype == self.DISTRIBUTION_SOURCE_PACKAGE_RTYPE:
355 for subtask in task.related_tasks:360 for subtask in task.related_tasks:
356 subtarget = self.lp.load(subtask.target.self_link)361 try:
362 subtarget = self.lp.load(subtask.target.self_link)
363 except NotFound:
364 return None
357 sub_rtype = get_rtype(subtarget)365 sub_rtype = get_rtype(subtarget)
358 if sub_rtype == self.SOURCE_PACKAGE_RTYPE:366 if sub_rtype == self.SOURCE_PACKAGE_RTYPE:
359 distro_name = (367 distro_name = (

Subscribers

People subscribed via source and target branches

to all changes: