summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/tracking.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/modules/tracking.py b/modules/tracking.py
index c5d292e..c86ef46 100644
--- a/modules/tracking.py
+++ b/modules/tracking.py
@@ -237,8 +237,9 @@ class TollpostModule(TrackingModule):
lastevent = item['events'][-1]
date = datetime.datetime.strptime(lastevent['eventTime'], '%Y-%m-%dT%H:%M:%S')
event = lastevent['eventDescription']
- location = lastevent['location']['name']
- status = '%s (%s)' % (event, location)
+ location = lastevent['location'].get('name') or lastevent['location'].get('city')
+ if location:
+ status = '%s (%s)' % (event, location)
results.append(TrackingResult(code, date, status.encode('utf-8'), delivered))
return results
@@ -270,8 +271,9 @@ class PostNordModule(TrackingModule):
lastevent = item['events'][-1]
date = datetime.datetime.strptime(lastevent['eventTime'], '%Y-%m-%dT%H:%M:%S')
event = lastevent['eventDescription']
- location = lastevent['location']['name']
- status = '%s (%s)' % (event, location)
+ location = lastevent['location'].get('name') or lastevent['location'].get('city')
+ if location:
+ status = '%s (%s)' % (event, location)
results.append(TrackingResult(code, date, status.encode('utf-8'), delivered))
return results