From edd6d64b9b7acb52285bbf56417139600509a018 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Wed, 25 Feb 2015 09:48:50 +0100 Subject: tracking: Fixed location for tollpost and PostNord. --- modules/tracking.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'modules') 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 -- cgit v1.2.3