summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2013-08-16 20:39:24 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2013-08-16 20:39:24 +0200
commit306b2a11a59d47e161c36a9e976428f6e0519edc (patch)
treeabb24f68340c894a795399adced6bcdb7c43ca67 /modules
parente0163dc2d1b9234bd3e2fa6c475911427fa6b74a (diff)
tracking: Say that no packages were found if the Posten API returns HTTP 404.
Diffstat (limited to 'modules')
-rw-r--r--modules/tracking.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/tracking.py b/modules/tracking.py
index 478ae9d..3fd6638 100644
--- a/modules/tracking.py
+++ b/modules/tracking.py
@@ -110,6 +110,10 @@ class PostenModule(TrackingModule):
def get_xml(self, url):
try:
u = urllib2.urlopen(url, timeout = config.getfloat(cfg_section, 'timeout'))
+ except urllib2.HTTPError as e:
+ if e.code == 404:
+ raise NoPackageFound('No packages found')
+ raise PackageError(str(e))
except Exception as e:
raise PackageError(str(e))
if u.headers['content-type'].startswith('application/xml'):
@@ -331,6 +335,9 @@ class Module:
for row in consignments:
try:
self.track_update(row.code, propagate_error = True)
+ except NoPackageFound:
+ results.append('No packages found for %s' % unicode(row))
+ continue
except PackageError as e:
results.append('Failed to fetch data for %s.' % unicode(row))
continue