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
1=== modified file 'lpworkitems/collect.py'
2--- lpworkitems/collect.py 2011-12-06 15:20:43 +0000
3+++ lpworkitems/collect.py 2013-01-18 16:49:21 +0000
4@@ -1,6 +1,8 @@
5 import datetime
6 import urllib
7
8+from lazr.restfulclient.errors import NotFound
9+
10 from lpworkitems import models
11 from lpworkitems.error_collector import MilestoneError
12
13@@ -313,7 +315,10 @@
14
15 def get_workitem_if_tracked(self, task, projects=None,
16 distro_release=None):
17- target = self.lp.load(task.target.self_link)
18+ try:
19+ target = self.lp.load(task.target.self_link)
20+ except NotFound:
21+ return None
22 def get_rtype(obj):
23 return urllib.splittag(obj.resource_type_link)[1]
24 rtype = get_rtype(target)
25@@ -353,7 +358,10 @@
26 return None
27 if rtype == self.DISTRIBUTION_SOURCE_PACKAGE_RTYPE:
28 for subtask in task.related_tasks:
29- subtarget = self.lp.load(subtask.target.self_link)
30+ try:
31+ subtarget = self.lp.load(subtask.target.self_link)
32+ except NotFound:
33+ return None
34 sub_rtype = get_rtype(subtarget)
35 if sub_rtype == self.SOURCE_PACKAGE_RTYPE:
36 distro_name = (

Subscribers

People subscribed via source and target branches

to all changes: