Subversion Repositories SmartDukaan

Rev

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

Rev 23139 Rev 23145
Line 11... Line 11...
11
from shop2020.utils.caching.SimpleCaching import memoized
11
from shop2020.utils.caching.SimpleCaching import memoized
12
import json
12
import json
13
import logging
13
import logging
14
import urllib
14
import urllib
15
import urllib2
15
import urllib2
-
 
16
import traceback
16
 
17
 
17
logging.basicConfig(level=logging.DEBUG)
18
logging.basicConfig(level=logging.DEBUG)
18
 
19
 
19
cc = ConfigClient()
20
cc = ConfigClient()
20
#live = cc.get_property("live")
21
#live = cc.get_property("live")
Line 114... Line 115...
114
    return awbs
115
    return awbs
115
 
116
 
116
#All orders awbwise
117
#All orders awbwise
117
#{'awb':[o1, o2, o3]}
118
#{'awb':[o1, o2, o3]}
118
def forward_request(airwaybill_no, logisticsTxnId):
119
def forward_request(airwaybill_no, logisticsTxnId):
-
 
120
    try:
119
    client = TransactionClient().get_client()
121
        client = TransactionClient().get_client()
120
    orders = client.getGroupOrdersByLogisticsTxnId(logisticsTxnId)
122
        orders = client.getGroupOrdersByLogisticsTxnId(logisticsTxnId)
121
    values = {'username' : username,
123
        values = {'username' : username,
122
              'password' : password,
124
                  'password' : password,
123
              'json_input' : _forwardMap(airwaybill_no, orders),
125
                  'json_input' : _forwardMap(airwaybill_no, orders),
124
              }
126
                  }
125
    print "values - ", values 
127
        print "values - ", values 
126
    data = urllib.urlencode(values)
128
        data = urllib.urlencode(values)
127
    print "data - ", data 
129
        print "data - ", data 
128
    req = urllib2.Request(forwardApi, data)
130
        req = urllib2.Request(forwardApi, data)
129
    response = urllib2.urlopen(req)
131
        response = urllib2.urlopen(req)
130
    the_page = response.read()
132
        the_page = response.read()
131
    jsonResponse = json.loads(the_page)
133
        jsonResponse = json.loads(the_page)
132
    return jsonResponse['success']
134
        return jsonResponse[0]['success']
-
 
135
    except:
-
 
136
        traceback.print_exc()
-
 
137
        return False
133
    
138
    
134
def _forwardMap(airwaybill_no, orders):
139
def _forwardMap(airwaybill_no, orders):
135
    shipments = []
140
    shipments = []
136
    shipments.append(_createShipment(airwaybill_no, orders))
141
    shipments.append(_createShipment(airwaybill_no, orders))
137
    return json.dumps(shipments)
142
    return json.dumps(shipments)