diff options
Diffstat (limited to 'modules')
-rwxr-xr-x[-rw-r--r--] | modules/tracking.py | 37 |
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' |