From 36e8396d207ee0ace524d1056b74cf641565aa48 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Thu, 30 Jul 2015 15:26:27 +0200 Subject: tracking: Removed tollpost. All tollpost tracking codes are also supported by PostNord. --- modules/tracking.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) mode change 100644 => 100755 modules/tracking.py (limited to 'modules') diff --git a/modules/tracking.py b/modules/tracking.py old mode 100644 new mode 100755 index 74997c4..1a09de4 --- 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' -- cgit v1.2.3