Subversion Repositories SmartDukaan

Rev

Rev 20726 | Rev 20768 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20726 Rev 20745
Line 15... Line 15...
15
LICENCE_KEY="5f1740fdfb8196e7980faea7fe52dd0d"
15
LICENCE_KEY="5f1740fdfb8196e7980faea7fe52dd0d"
16
API_VERSION="1.7"
16
API_VERSION="1.7"
17
API_TYPE="S"
17
API_TYPE="S"
18
AREA="ALL"
18
AREA="ALL"
19
 
19
 
-
 
20
class __BluedartAWBResponse:
-
 
21
    def __init__(self, awbNo, destArea, destLocation):
-
 
22
        self.awbNo = awbNo
-
 
23
        self.destArea = destArea
-
 
24
        self.destLocation = destLocation
-
 
25
 
20
def get_client():
26
def get_client():
21
    global raclient
27
    global raclient
22
    if raclient is None:
28
    if raclient is None:
23
        raclient = Client(acc_url, timeout=70)
29
        raclient = Client(acc_url, timeout=70)
24
        return raclient
30
        return raclient
Line 108... Line 114...
108
        d= get_client().factory.create('ns2:Dimension')
114
        d= get_client().factory.create('ns2:Dimension')
109
        d.Count=0
115
        d.Count=0
110
        ser.Dimensions=[d]
116
        ser.Dimensions=[d]
111
        response = get_client().service.GenerateWayBill(wbg, get_profile())
117
        response = get_client().service.GenerateWayBill(wbg, get_profile())
112
        if response.AWBNo is None:
118
        if response.AWBNo is None:
113
            #Lets check whether awb has been generated before for the same reference
-
 
114
            #No error code is given, will have to try dirty method
119
            raise RuntimeError("AWB generated is empty")
115
            status_info = (response.Status.WayBillGenerationStatus[0].StatusInformation)
-
 
116
            matched = re.findall(r"\D(\d{11})\D", " "+status_info+" ")
-
 
117
            if len(matched)==1:
-
 
118
                return str(matched[0])
-
 
119
        else:
120
        else:
-
 
121
            bluedartResponse = __BluedartAWBResponse(str(response.AWBNo),str(response.DestinationArea),str(response.DestinationLocation))
120
            return str(response.AWBNo)
122
            return bluedartResponse
121
    finally:
123
    finally:
122
        if DEBUG:
124
        if DEBUG:
123
            print get_client().last_sent()
125
            print get_client().last_sent()
124
            print get_client().last_received()
126
            print get_client().last_received()
125
 
127