| 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)'
|
| 412 |
ashish |
37 |
print ''
|
|
|
38 |
sys.exit(0)
|
|
|
39 |
|
|
|
40 |
pp = pprint.PrettyPrinter(indent = 2)
|
|
|
41 |
host = 'localhost'
|
|
|
42 |
port = 9090
|
|
|
43 |
uri = ''
|
|
|
44 |
framed = False
|
|
|
45 |
http = False
|
|
|
46 |
argi = 1
|
|
|
47 |
|
|
|
48 |
if sys.argv[argi] == '-h':
|
| 3431 |
rajveer |
49 |
parts = sys.argv[argi+1].split(':')
|
| 412 |
ashish |
50 |
host = parts[0]
|
|
|
51 |
port = int(parts[1])
|
|
|
52 |
argi += 2
|
|
|
53 |
|
|
|
54 |
if sys.argv[argi] == '-u':
|
|
|
55 |
url = urlparse(sys.argv[argi+1])
|
| 3431 |
rajveer |
56 |
parts = url[1].split(':')
|
| 412 |
ashish |
57 |
host = parts[0]
|
|
|
58 |
if len(parts) > 1:
|
|
|
59 |
port = int(parts[1])
|
|
|
60 |
else:
|
|
|
61 |
port = 80
|
|
|
62 |
uri = url[2]
|
| 3431 |
rajveer |
63 |
if url[4]:
|
|
|
64 |
uri += '?%s' % url[4]
|
| 412 |
ashish |
65 |
http = True
|
|
|
66 |
argi += 2
|
|
|
67 |
|
|
|
68 |
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
|
|
|
69 |
framed = True
|
|
|
70 |
argi += 1
|
|
|
71 |
|
|
|
72 |
cmd = sys.argv[argi]
|
|
|
73 |
args = sys.argv[argi+1:]
|
|
|
74 |
|
|
|
75 |
if http:
|
|
|
76 |
transport = THttpClient.THttpClient(host, port, uri)
|
|
|
77 |
else:
|
|
|
78 |
socket = TSocket.TSocket(host, port)
|
|
|
79 |
if framed:
|
|
|
80 |
transport = TTransport.TFramedTransport(socket)
|
|
|
81 |
else:
|
|
|
82 |
transport = TTransport.TBufferedTransport(socket)
|
|
|
83 |
protocol = TBinaryProtocol.TBinaryProtocol(transport)
|
|
|
84 |
client = LogisticsService.Client(protocol)
|
|
|
85 |
transport.open()
|
|
|
86 |
|
| 3376 |
rajveer |
87 |
if cmd == 'getProvider':
|
| 669 |
chandransh |
88 |
if len(args) != 1:
|
|
|
89 |
print 'getProvider requires 1 args'
|
|
|
90 |
sys.exit(1)
|
|
|
91 |
pp.pprint(client.getProvider(eval(args[0]),))
|
|
|
92 |
|
| 675 |
chandransh |
93 |
elif cmd == 'getAllProviders':
|
|
|
94 |
if len(args) != 0:
|
|
|
95 |
print 'getAllProviders requires 0 args'
|
|
|
96 |
sys.exit(1)
|
|
|
97 |
pp.pprint(client.getAllProviders())
|
|
|
98 |
|
| 669 |
chandransh |
99 |
elif cmd == 'getLogisticsEstimation':
|
| 4630 |
mandeep.dh |
100 |
if len(args) != 3:
|
|
|
101 |
print 'getLogisticsEstimation requires 3 args'
|
| 483 |
rajveer |
102 |
sys.exit(1)
|
| 4630 |
mandeep.dh |
103 |
pp.pprint(client.getLogisticsEstimation(eval(args[0]),args[1],eval(args[2]),))
|
| 483 |
rajveer |
104 |
|
| 647 |
chandransh |
105 |
elif cmd == 'getLogisticsInfo':
|
| 3044 |
chandransh |
106 |
if len(args) != 3:
|
|
|
107 |
print 'getLogisticsInfo requires 3 args'
|
| 412 |
ashish |
108 |
sys.exit(1)
|
| 3044 |
chandransh |
109 |
pp.pprint(client.getLogisticsInfo(args[0],eval(args[1]),eval(args[2]),))
|
| 412 |
ashish |
110 |
|
|
|
111 |
elif cmd == 'getEmptyAWB':
|
| 5247 |
rajveer |
112 |
if len(args) != 2:
|
|
|
113 |
print 'getEmptyAWB requires 2 args'
|
| 412 |
ashish |
114 |
sys.exit(1)
|
| 5247 |
rajveer |
115 |
pp.pprint(client.getEmptyAWB(eval(args[0]),eval(args[1]),))
|
| 412 |
ashish |
116 |
|
|
|
117 |
elif cmd == 'getShipmentInfo':
|
| 647 |
chandransh |
118 |
if len(args) != 2:
|
|
|
119 |
print 'getShipmentInfo requires 2 args'
|
| 412 |
ashish |
120 |
sys.exit(1)
|
| 647 |
chandransh |
121 |
pp.pprint(client.getShipmentInfo(args[0],eval(args[1]),))
|
| 412 |
ashish |
122 |
|
| 732 |
chandransh |
123 |
elif cmd == 'getDestinationCode':
|
|
|
124 |
if len(args) != 2:
|
|
|
125 |
print 'getDestinationCode requires 2 args'
|
|
|
126 |
sys.exit(1)
|
|
|
127 |
pp.pprint(client.getDestinationCode(eval(args[0]),args[1],))
|
|
|
128 |
|
| 1137 |
chandransh |
129 |
elif cmd == 'getFreeAwbCount':
|
| 3103 |
chandransh |
130 |
if len(args) != 2:
|
|
|
131 |
print 'getFreeAwbCount requires 2 args'
|
| 1137 |
chandransh |
132 |
sys.exit(1)
|
| 3103 |
chandransh |
133 |
pp.pprint(client.getFreeAwbCount(eval(args[0]),args[1],))
|
| 1137 |
chandransh |
134 |
|
| 1730 |
ankur.sing |
135 |
elif cmd == 'getHolidays':
|
|
|
136 |
if len(args) != 2:
|
|
|
137 |
print 'getHolidays requires 2 args'
|
|
|
138 |
sys.exit(1)
|
|
|
139 |
pp.pprint(client.getHolidays(eval(args[0]),eval(args[1]),))
|
|
|
140 |
|
| 4934 |
amit.gupta |
141 |
elif cmd == 'getEntityLogisticsEstimation':
|
|
|
142 |
if len(args) != 3:
|
|
|
143 |
print 'getEntityLogisticsEstimation requires 3 args'
|
|
|
144 |
sys.exit(1)
|
|
|
145 |
pp.pprint(client.getEntityLogisticsEstimation(eval(args[0]),args[1],eval(args[2]),))
|
|
|
146 |
|
| 5527 |
anupam.sin |
147 |
elif cmd == 'getProviderForPickupType':
|
|
|
148 |
if len(args) != 1:
|
|
|
149 |
print 'getProviderForPickupType requires 1 args'
|
|
|
150 |
sys.exit(1)
|
|
|
151 |
pp.pprint(client.getProviderForPickupType(eval(args[0]),))
|
|
|
152 |
|
| 5553 |
rajveer |
153 |
elif cmd == 'getAllPickupStores':
|
|
|
154 |
if len(args) != 0:
|
|
|
155 |
print 'getAllPickupStores requires 0 args'
|
|
|
156 |
sys.exit(1)
|
|
|
157 |
pp.pprint(client.getAllPickupStores())
|
|
|
158 |
|
|
|
159 |
elif cmd == 'getPickupStore':
|
|
|
160 |
if len(args) != 1:
|
|
|
161 |
print 'getPickupStore requires 1 args'
|
|
|
162 |
sys.exit(1)
|
|
|
163 |
pp.pprint(client.getPickupStore(eval(args[0]),))
|
|
|
164 |
|
| 3431 |
rajveer |
165 |
else:
|
|
|
166 |
print 'Unrecognized method %s' % cmd
|
|
|
167 |
sys.exit(1)
|
|
|
168 |
|
| 412 |
ashish |
169 |
transport.close()
|