summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2015-07-30 15:27:48 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2015-07-30 15:27:48 +0200
commit4011141108f5992f8231208ba9f42d52da2e4d0e (patch)
tree12e6e66d14e2f458a4dad645f01d7af6178d6af3
parent36e8396d207ee0ace524d1056b74cf641565aa48 (diff)
tracking: Fixed errors on missing fields in PostNord.
-rwxr-xr-xmodules/tracking.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/tracking.py b/modules/tracking.py
index 1a09de4..1e74001 100755
--- a/modules/tracking.py
+++ b/modules/tracking.py
@@ -231,11 +231,13 @@ class PostNordModule(TrackingModule):
for shipment in response['shipments']:
for item in shipment['items']:
code = item['itemId']
- delivered = (item['status'] == 'DELIVERED')
+ delivered = (item.get('status') == 'DELIVERED')
lastevent = item['events'][-1]
date = datetime.datetime.strptime(lastevent['eventTime'], '%Y-%m-%dT%H:%M:%S')
event = lastevent['eventDescription']
- location = lastevent['location'].get('name') or lastevent['location'].get('city')
+ location = lastevent.get('location')
+ if location:
+ location = lastevent['location'].get('name') or lastevent['location'].get('city')
if location:
status = '%s (%s)' % (event, location)
else: