summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/tracking.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/tracking.py b/modules/tracking.py
index 0597832..40e7e44 100644
--- a/modules/tracking.py
+++ b/modules/tracking.py
@@ -176,7 +176,10 @@ class FedexModule(TrackingModule):
code = self.splitcode(code)
data = {'TrackPackagesRequest': {'appType': 'wtrk', 'uniqueKey': '', 'processingParameters': {'anonymousTransaction': True, 'clientId': 'WTRK', 'returnDetailedErrors': True, 'returnLocalizedDateTime': False}, 'trackingInfoList': [{'trackNumberInfo': {'trackingNumber': code, 'trackingQualifier': '', 'trackingCarrier': ''}}]}}
url = 'https://www.fedex.com/trackingCal/track?' + urllib.urlencode({'data': json.dumps(data), 'action': 'trackpackages', 'locale': 'en_US', 'format': 'json', 'version': 99})
- u = urllib2.urlopen(url)
+ try:
+ u = urllib2.urlopen(url)
+ except urllib2.HTTPError as e:
+ raise PackageError(str(e))
data = u.read()
u.close()
for m in re.findall(r'(\\x[a-fA-F\d]{2})', data):
@@ -215,7 +218,10 @@ class TollpostModule(TrackingModule):
code = self.splitcode(code)
url = 'http://www.tollpost.no/XMLServer/rest/trackandtrace'
data = urllib.urlencode({'q': code})
- u = urllib2.urlopen(url, data)
+ try:
+ u = urllib2.urlopen(url, data)
+ except urllib2.HTTPError as e:
+ raise PackageError(str(e))
data = u.read()
u.close()
data = json.loads(data)