| 412 |
ashish |
1 |
#!/usr/bin/env python
|
|
|
2 |
#
|
| 3431 |
rajveer |
3 |
# Autogenerated by Thrift Compiler (0.7.0)
|
| 412 |
ashish |
4 |
#
|
|
|
5 |
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
|
6 |
#
|
|
|
7 |
|
|
|
8 |
import sys
|
|
|
9 |
import pprint
|
|
|
10 |
from urlparse import urlparse
|
|
|
11 |
from thrift.transport import TTransport
|
|
|
12 |
from thrift.transport import TSocket
|
|
|
13 |
from thrift.transport import THttpClient
|
|
|
14 |
from thrift.protocol import TBinaryProtocol
|
|
|
15 |
|
|
|
16 |
import LogisticsService
|
|
|
17 |
from ttypes import *
|
|
|
18 |
|
|
|
19 |
if len(sys.argv) <= 1 or sys.argv[1] == '--help':
|
|
|
20 |
print ''
|
|
|
21 |
print 'Usage: ' + sys.argv[0] + ' [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
|
|
|
22 |
print ''
|
|
|
23 |
print 'Functions:'
|
| 669 |
chandransh |
24 |
print ' Provider getProvider(i64 providerId)'
|
| 675 |
chandransh |
25 |
print ' getAllProviders()'
|
| 4630 |
mandeep.dh |
26 |
print ' LogisticsInfo getLogisticsEstimation(i64 itemId, string destination_pin, DeliveryType type)'
|
| 3044 |
chandransh |
27 |
print ' LogisticsInfo getLogisticsInfo(string destination_pincode, i64 item_id, DeliveryType type)'
|
| 5247 |
rajveer |
28 |
print ' string getEmptyAWB(i64 providerId, DeliveryType type)'
|
| 647 |
chandransh |
29 |
print ' getShipmentInfo(string awb, i64 providerId)'
|
| 732 |
chandransh |
30 |
print ' string getDestinationCode(i64 providerId, string pinCode)'
|
| 3103 |
chandransh |
31 |
print ' i64 getFreeAwbCount(i64 providerId, string type)'
|
| 1730 |
ankur.sing |
32 |
print ' getHolidays(i64 fromDate, i64 toDate)'
|
| 4934 |
amit.gupta |
33 |
print ' getEntityLogisticsEstimation(i64 catalogItemId, string destination_pin, DeliveryType type)'
|
| 5527 |
anupam.sin |
34 |
print ' i64 getProviderForPickupType(i64 pickUp)'
|
| 5553 |
rajveer |
35 |
print ' getAllPickupStores()'
|
|
|
36 |
print ' PickupStore getPickupStore(i64 storeId)'
|
| 5719 |
rajveer |
37 |
print ' PickupStore getPickupStoreByHotspotId(string hotspotId)'
|
| 412 |
ashish |
38 |
print ''
|
|
|
39 |
sys.exit(0)
|
|
|
40 |
|
|
|
41 |
pp = pprint.PrettyPrinter(indent = 2)
|
|
|
42 |
host = 'localhost'
|
|
|
43 |
port = 9090
|
|
|
44 |
uri = ''
|
|
|
45 |
framed = False
|
|
|
46 |
http = False
|
|
|
47 |
argi = 1
|
|
|
48 |
|
|
|
49 |
if sys.argv[argi] == '-h':
|
| 3431 |
rajveer |
50 |
parts = sys.argv[argi+1].split(':')
|
| 412 |
ashish |
51 |
host = parts[0]
|
|
|
52 |
port = int(parts[1])
|
|
|
53 |
argi += 2
|
|
|
54 |
|
|
|
55 |
if sys.argv[argi] == '-u':
|
|
|
56 |
url = urlparse(sys.argv[argi+1])
|
| 3431 |
rajveer |
57 |
parts = url[1].split(':')
|
| 412 |
ashish |
58 |
host = parts[0]
|
|
|
59 |
if len(parts) > 1:
|
|
|
60 |
port = int(parts[1])
|
|
|
61 |
else:
|
|
|
62 |
port = 80
|
|
|
63 |
uri = url[2]
|
| 3431 |
rajveer |
64 |
if url[4]:
|
|
|
65 |
uri += '?%s' % url[4]
|
| 412 |
ashish |
66 |
http = True
|
|
|
67 |
argi += 2
|
|
|
68 |
|
|
|
69 |
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
|
|
|
70 |
framed = True
|
|
|
71 |
argi += 1
|
|
|
72 |
|
|
|
73 |
cmd = sys.argv[argi]
|
|
|
74 |
args = sys.argv[argi+1:]
|
|
|
75 |
|
|
|
76 |
if http:
|
|
|
77 |
transport = THttpClient.THttpClient(host, port, uri)
|
|
|
78 |
else:
|
|
|
79 |
socket = TSocket.TSocket(host, port)
|
|
|
80 |
if framed:
|
|
|
81 |
transport = TTransport.TFramedTransport(socket)
|
|
|
82 |
else:
|
|
|
83 |
transport = TTransport.TBufferedTransport(socket)
|
|
|
84 |
protocol = TBinaryProtocol.TBinaryProtocol(transport)
|
|
|
85 |
client = LogisticsService.Client(protocol)
|
|
|
86 |
transport.open()
|
|
|
87 |
|
| 3376 |
rajveer |
88 |
if cmd == 'getProvider':
|
| 669 |
chandransh |
89 |
if len(args) != 1:
|
|
|
90 |
print 'getProvider requires 1 args'
|
|
|
91 |
sys.exit(1)
|
|
|
92 |
pp.pprint(client.getProvider(eval(args[0]),))
|
|
|
93 |
|
| 675 |
chandransh |
94 |
elif cmd == 'getAllProviders':
|
|
|
95 |
if len(args) != 0:
|
|
|
96 |
print 'getAllProviders requires 0 args'
|
|
|
97 |
sys.exit(1)
|
|
|
98 |
pp.pprint(client.getAllProviders())
|
|
|
99 |
|
| 669 |
chandransh |
100 |
elif cmd == 'getLogisticsEstimation':
|
| 4630 |
mandeep.dh |
101 |
if len(args) != 3:
|
|
|
102 |
print 'getLogisticsEstimation requires 3 args'
|
| 483 |
rajveer |
103 |
sys.exit(1)
|
| 4630 |
mandeep.dh |
104 |
pp.pprint(client.getLogisticsEstimation(eval(args[0]),args[1],eval(args[2]),))
|
| 483 |
rajveer |
105 |
|
| 647 |
chandransh |
106 |
elif cmd == 'getLogisticsInfo':
|
| 3044 |
chandransh |
107 |
if len(args) != 3:
|
|
|
108 |
print 'getLogisticsInfo requires 3 args'
|
| 412 |
ashish |
109 |
sys.exit(1)
|
| 3044 |
chandransh |
110 |
pp.pprint(client.getLogisticsInfo(args[0],eval(args[1]),eval(args[2]),))
|
| 412 |
ashish |
111 |
|
|
|
112 |
elif cmd == 'getEmptyAWB':
|
| 5247 |
rajveer |
113 |
if len(args) != 2:
|
|
|
114 |
print 'getEmptyAWB requires 2 args'
|
| 412 |
ashish |
115 |
sys.exit(1)
|
| 5247 |
rajveer |
116 |
pp.pprint(client.getEmptyAWB(eval(args[0]),eval(args[1]),))
|
| 412 |
ashish |
117 |
|
|
|
118 |
elif cmd == 'getShipmentInfo':
|
| 647 |
chandransh |
119 |
if len(args) != 2:
|
|
|
120 |
print 'getShipmentInfo requires 2 args'
|
| 412 |
ashish |
121 |
sys.exit(1)
|
| 647 |
chandransh |
122 |
pp.pprint(client.getShipmentInfo(args[0],eval(args[1]),))
|
| 412 |
ashish |
123 |
|
| 732 |
chandransh |
124 |
elif cmd == 'getDestinationCode':
|
|
|
125 |
if len(args) != 2:
|
|
|
126 |
print 'getDestinationCode requires 2 args'
|
|
|
127 |
sys.exit(1)
|
|
|
128 |
pp.pprint(client.getDestinationCode(eval(args[0]),args[1],))
|
|
|
129 |
|
| 1137 |
chandransh |
130 |
elif cmd == 'getFreeAwbCount':
|
| 3103 |
chandransh |
131 |
if len(args) != 2:
|
|
|
132 |
print 'getFreeAwbCount requires 2 args'
|
| 1137 |
chandransh |
133 |
sys.exit(1)
|
| 3103 |
chandransh |
134 |
pp.pprint(client.getFreeAwbCount(eval(args[0]),args[1],))
|
| 1137 |
chandransh |
135 |
|
| 1730 |
ankur.sing |
136 |
elif cmd == 'getHolidays':
|
|
|
137 |
if len(args) != 2:
|
|
|
138 |
print 'getHolidays requires 2 args'
|
|
|
139 |
sys.exit(1)
|
|
|
140 |
pp.pprint(client.getHolidays(eval(args[0]),eval(args[1]),))
|
|
|
141 |
|
| 4934 |
amit.gupta |
142 |
elif cmd == 'getEntityLogisticsEstimation':
|
|
|
143 |
if len(args) != 3:
|
|
|
144 |
print 'getEntityLogisticsEstimation requires 3 args'
|
|
|
145 |
sys.exit(1)
|
|
|
146 |
pp.pprint(client.getEntityLogisticsEstimation(eval(args[0]),args[1],eval(args[2]),))
|
|
|
147 |
|
| 5527 |
anupam.sin |
148 |
elif cmd == 'getProviderForPickupType':
|
|
|
149 |
if len(args) != 1:
|
|
|
150 |
print 'getProviderForPickupType requires 1 args'
|
|
|
151 |
sys.exit(1)
|
|
|
152 |
pp.pprint(client.getProviderForPickupType(eval(args[0]),))
|
|
|
153 |
|
| 5553 |
rajveer |
154 |
elif cmd == 'getAllPickupStores':
|
|
|
155 |
if len(args) != 0:
|
|
|
156 |
print 'getAllPickupStores requires 0 args'
|
|
|
157 |
sys.exit(1)
|
|
|
158 |
pp.pprint(client.getAllPickupStores())
|
|
|
159 |
|
|
|
160 |
elif cmd == 'getPickupStore':
|
|
|
161 |
if len(args) != 1:
|
|
|
162 |
print 'getPickupStore requires 1 args'
|
|
|
163 |
sys.exit(1)
|
|
|
164 |
pp.pprint(client.getPickupStore(eval(args[0]),))
|
|
|
165 |
|
| 5719 |
rajveer |
166 |
elif cmd == 'getPickupStoreByHotspotId':
|
|
|
167 |
if len(args) != 1:
|
|
|
168 |
print 'getPickupStoreByHotspotId requires 1 args'
|
|
|
169 |
sys.exit(1)
|
|
|
170 |
pp.pprint(client.getPickupStoreByHotspotId(args[0],))
|
|
|
171 |
|
| 3431 |
rajveer |
172 |
else:
|
|
|
173 |
print 'Unrecognized method %s' % cmd
|
|
|
174 |
sys.exit(1)
|
|
|
175 |
|
| 412 |
ashish |
176 |
transport.close()
|