summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2015-07-30 15:26:27 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2015-07-30 15:26:27 +0200
commit36e8396d207ee0ace524d1056b74cf641565aa48 (patch)
tree8ede7c9d48bd48d45c63e57ef022c17a89960d1e /modules
parent099331018f1f42ad5d77473f7d3d6cc3527fdb67 (diff)
tracking: Removed tollpost.
All tollpost tracking codes are also supported by PostNord.
Diffstat (limited to 'modules')
-rwxr-xr-x[-rw-r--r--]modules/tracking.py37
1 files changed, 0 insertions, 37 deletions
diff --git a/modules/tracking.py b/modules/tracking.py
index 74997c4..1a09de4 100644..100755
--- a/modules/tracking.py
+++ b/modules/tracking.py
@@ -208,43 +208,6 @@ class FedexModule(TrackingModule):
results.append(TrackingResult(code, date, status, lastevent['isDelivered']))
return results
-class TollpostModule(TrackingModule):
- name = 'tollpost'
-
- def get_url(self, code = None):
- url = 'http://www.tollpost.no/minside/SOPS/'
- if code:
- url += 'consignment/' + code
- return url
-
- def track(self, code):
- code = self.splitcode(code)
- url = 'http://www.tollpost.no/XMLServer/rest/trackandtrace'
- data = urllib.urlencode({'q': code})
- try:
- u = urllib2.urlopen(url, data)
- except urllib2.HTTPError as e:
- raise PackageError(str(e))
- data = u.read()
- u.close()
- data = json.loads(data)
- response = data['TrackingInformationResponse']
- results = []
- for shipment in response['shipments']:
- for item in shipment['items']:
- code = item['itemId']
- delivered = (item['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')
- if location:
- status = '%s (%s)' % (event, location)
- else:
- status = event
- results.append(TrackingResult(code, date, status.encode('utf-8'), delivered))
- return results
-
class PostNordModule(TrackingModule):
name = 'postnord'