summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-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: