summaryrefslogtreecommitdiff
path: root/modules/tracking.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/tracking.py')
-rwxr-xr-xmodules/tracking.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/tracking.py b/modules/tracking.py
index b59bc05..917c960 100755
--- a/modules/tracking.py
+++ b/modules/tracking.py
@@ -304,7 +304,12 @@ class UpsModule(TrackingModule):
continue
address = activity.find('ActivityLocation/Address')
- location_text = "%s, %s" % (address.find('City').text, address.find('CountryCode').text)
+ city = address.find('City')
+ cc = address.find('CountryCode')
+ if city is not None and cc is not None:
+ location_text = "%s, %s" % (city.text, cc.text)
+ else:
+ location_text = None
statuscode = activity.find('Status/StatusType/Code').text
event_text = activity.find('Status/StatusType/Description').text
date = activity.find('Date').text
@@ -312,7 +317,9 @@ class UpsModule(TrackingModule):
year, month, day = int(date[0:4]), int(date[4:6]), int(date[6:8])
hour, minute, second = int(time[0:2]), int(time[2:4]), int(time[4:6])
isodate = datetime.datetime(year, month, day, hour, minute, second)
- desc = "%s (%s)" % (event_text, location_text)
+ desc = event_text
+ if location_text:
+ desc += " (%s)" % location_text
results.append(TrackingResult(code, isodate, desc, statuscode == 'D'))
return results