| 7028 |
rajveer |
1 |
from shop2020.utils.Utils import to_py_date
|
|
|
2 |
from xml.etree.ElementTree import parse, XML, fromstring
|
|
|
3 |
from suds.client import Client
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
RED_EXPRESS_URL = "http://tracking.getsetred.net/TrackingService.svc?wsdl"
|
|
|
7 |
username = 'C00086721141'
|
|
|
8 |
password = 'SANDEEP.SACHDEVA@SHOP2020.IN'
|
|
|
9 |
|
|
|
10 |
client = None
|
|
|
11 |
def getClient():
|
|
|
12 |
global client
|
|
|
13 |
if client is None:
|
|
|
14 |
client = Client(RED_EXPRESS_URL, timeout=70)
|
|
|
15 |
return client
|
|
|
16 |
|
|
|
17 |
def get_updates(awb_number):
|
|
|
18 |
str = getClient().service.ProcessTrackingRequest('<TrackingRequest><Request><UserID>' + username + '</UserID><Password>' + password + '</Password><TrackingID>' + awb_number + '</TrackingID><TrackingLevel>ALL_DETAILS</TrackingLevel></Request></TrackingRequest>')
|
|
|
19 |
print str
|
|
|
20 |
return str
|
|
|
21 |
|
|
|
22 |
def get_updates_for_user(awb_number):
|
|
|
23 |
root = fromstring(str(get_updates(awb_number)))
|
|
|
24 |
children = root.getchildren()
|
|
|
25 |
results = []
|
|
|
26 |
for child in children:
|
|
|
27 |
nodes = child.findall('ShipmentInfo/ShipmentEvent')
|
|
|
28 |
for element in reversed(nodes):
|
|
|
29 |
datestring = element.findtext('Date', '')
|
|
|
30 |
timestring = element.findtext('Time', '')
|
|
|
31 |
description = element.findtext('ServiceEvent', '')
|
|
|
32 |
results.append(datestring+"~!~"+timestring+"~!~"+description)
|
|
|
33 |
return results
|