Subversion Repositories SmartDukaan

Rev

Rev 6643 | Rev 7567 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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)'
7256 rajveer 27
  print '  LogisticsInfo getLogisticsEstimationForStore(i64 itemId, string destination_pin, DeliveryType type)'
5767 rajveer 28
  print '  LogisticsInfo getLogisticsInfo(string destination_pincode, i64 item_id, DeliveryType type, PickUpType pickUp)'
5247 rajveer 29
  print '  string getEmptyAWB(i64 providerId, DeliveryType type)'
6643 rajveer 30
  print '   getShipmentInfo(string awbNumber, i64 providerId)'
31
  print '  void storeShipmentInfo(AwbUpdate update)'
732 chandransh 32
  print '  string getDestinationCode(i64 providerId, string pinCode)'
3103 chandransh 33
  print '  i64 getFreeAwbCount(i64 providerId, string type)'
1730 ankur.sing 34
  print '   getHolidays(i64 fromDate, i64 toDate)'
4934 amit.gupta 35
  print '   getEntityLogisticsEstimation(i64 catalogItemId, string destination_pin, DeliveryType type)'
5527 anupam.sin 36
  print '  i64 getProviderForPickupType(i64 pickUp)'
5553 rajveer 37
  print '   getAllPickupStores()'
38
  print '  PickupStore getPickupStore(i64 storeId)'
5719 rajveer 39
  print '  PickupStore getPickupStoreByHotspotId(string hotspotId)'
6524 rajveer 40
  print '  void addPincode(i64 providerId, string pincode, string destCode, bool exp, bool cod, i32 stationType, bool otgAvailable)'
41
  print '  void updatePincode(i64 providerId, string pincode, bool exp, bool cod, bool otgAvailable)'
412 ashish 42
  print ''
43
  sys.exit(0)
44
 
45
pp = pprint.PrettyPrinter(indent = 2)
46
host = 'localhost'
47
port = 9090
48
uri = ''
49
framed = False
50
http = False
51
argi = 1
52
 
53
if sys.argv[argi] == '-h':
3431 rajveer 54
  parts = sys.argv[argi+1].split(':')
412 ashish 55
  host = parts[0]
56
  port = int(parts[1])
57
  argi += 2
58
 
59
if sys.argv[argi] == '-u':
60
  url = urlparse(sys.argv[argi+1])
3431 rajveer 61
  parts = url[1].split(':')
412 ashish 62
  host = parts[0]
63
  if len(parts) > 1:
64
    port = int(parts[1])
65
  else:
66
    port = 80
67
  uri = url[2]
3431 rajveer 68
  if url[4]:
69
    uri += '?%s' % url[4]
412 ashish 70
  http = True
71
  argi += 2
72
 
73
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
74
  framed = True
75
  argi += 1
76
 
77
cmd = sys.argv[argi]
78
args = sys.argv[argi+1:]
79
 
80
if http:
81
  transport = THttpClient.THttpClient(host, port, uri)
82
else:
83
  socket = TSocket.TSocket(host, port)
84
  if framed:
85
    transport = TTransport.TFramedTransport(socket)
86
  else:
87
    transport = TTransport.TBufferedTransport(socket)
88
protocol = TBinaryProtocol.TBinaryProtocol(transport)
89
client = LogisticsService.Client(protocol)
90
transport.open()
91
 
3376 rajveer 92
if cmd == 'getProvider':
669 chandransh 93
  if len(args) != 1:
94
    print 'getProvider requires 1 args'
95
    sys.exit(1)
96
  pp.pprint(client.getProvider(eval(args[0]),))
97
 
675 chandransh 98
elif cmd == 'getAllProviders':
99
  if len(args) != 0:
100
    print 'getAllProviders requires 0 args'
101
    sys.exit(1)
102
  pp.pprint(client.getAllProviders())
103
 
669 chandransh 104
elif cmd == 'getLogisticsEstimation':
4630 mandeep.dh 105
  if len(args) != 3:
106
    print 'getLogisticsEstimation requires 3 args'
483 rajveer 107
    sys.exit(1)
4630 mandeep.dh 108
  pp.pprint(client.getLogisticsEstimation(eval(args[0]),args[1],eval(args[2]),))
483 rajveer 109
 
7256 rajveer 110
elif cmd == 'getLogisticsEstimationForStore':
111
  if len(args) != 3:
112
    print 'getLogisticsEstimationForStore requires 3 args'
113
    sys.exit(1)
114
  pp.pprint(client.getLogisticsEstimationForStore(eval(args[0]),args[1],eval(args[2]),))
115
 
647 chandransh 116
elif cmd == 'getLogisticsInfo':
5767 rajveer 117
  if len(args) != 4:
118
    print 'getLogisticsInfo requires 4 args'
412 ashish 119
    sys.exit(1)
5767 rajveer 120
  pp.pprint(client.getLogisticsInfo(args[0],eval(args[1]),eval(args[2]),eval(args[3]),))
412 ashish 121
 
122
elif cmd == 'getEmptyAWB':
5247 rajveer 123
  if len(args) != 2:
124
    print 'getEmptyAWB requires 2 args'
412 ashish 125
    sys.exit(1)
5247 rajveer 126
  pp.pprint(client.getEmptyAWB(eval(args[0]),eval(args[1]),))
412 ashish 127
 
128
elif cmd == 'getShipmentInfo':
647 chandransh 129
  if len(args) != 2:
130
    print 'getShipmentInfo requires 2 args'
412 ashish 131
    sys.exit(1)
647 chandransh 132
  pp.pprint(client.getShipmentInfo(args[0],eval(args[1]),))
412 ashish 133
 
6643 rajveer 134
elif cmd == 'storeShipmentInfo':
135
  if len(args) != 1:
136
    print 'storeShipmentInfo requires 1 args'
137
    sys.exit(1)
138
  pp.pprint(client.storeShipmentInfo(eval(args[0]),))
139
 
732 chandransh 140
elif cmd == 'getDestinationCode':
141
  if len(args) != 2:
142
    print 'getDestinationCode requires 2 args'
143
    sys.exit(1)
144
  pp.pprint(client.getDestinationCode(eval(args[0]),args[1],))
145
 
1137 chandransh 146
elif cmd == 'getFreeAwbCount':
3103 chandransh 147
  if len(args) != 2:
148
    print 'getFreeAwbCount requires 2 args'
1137 chandransh 149
    sys.exit(1)
3103 chandransh 150
  pp.pprint(client.getFreeAwbCount(eval(args[0]),args[1],))
1137 chandransh 151
 
1730 ankur.sing 152
elif cmd == 'getHolidays':
153
  if len(args) != 2:
154
    print 'getHolidays requires 2 args'
155
    sys.exit(1)
156
  pp.pprint(client.getHolidays(eval(args[0]),eval(args[1]),))
157
 
4934 amit.gupta 158
elif cmd == 'getEntityLogisticsEstimation':
159
  if len(args) != 3:
160
    print 'getEntityLogisticsEstimation requires 3 args'
161
    sys.exit(1)
162
  pp.pprint(client.getEntityLogisticsEstimation(eval(args[0]),args[1],eval(args[2]),))
163
 
5527 anupam.sin 164
elif cmd == 'getProviderForPickupType':
165
  if len(args) != 1:
166
    print 'getProviderForPickupType requires 1 args'
167
    sys.exit(1)
168
  pp.pprint(client.getProviderForPickupType(eval(args[0]),))
169
 
5553 rajveer 170
elif cmd == 'getAllPickupStores':
171
  if len(args) != 0:
172
    print 'getAllPickupStores requires 0 args'
173
    sys.exit(1)
174
  pp.pprint(client.getAllPickupStores())
175
 
176
elif cmd == 'getPickupStore':
177
  if len(args) != 1:
178
    print 'getPickupStore requires 1 args'
179
    sys.exit(1)
180
  pp.pprint(client.getPickupStore(eval(args[0]),))
181
 
5719 rajveer 182
elif cmd == 'getPickupStoreByHotspotId':
183
  if len(args) != 1:
184
    print 'getPickupStoreByHotspotId requires 1 args'
185
    sys.exit(1)
186
  pp.pprint(client.getPickupStoreByHotspotId(args[0],))
187
 
6524 rajveer 188
elif cmd == 'addPincode':
189
  if len(args) != 7:
190
    print 'addPincode requires 7 args'
191
    sys.exit(1)
192
  pp.pprint(client.addPincode(eval(args[0]),args[1],args[2],eval(args[3]),eval(args[4]),eval(args[5]),eval(args[6]),))
193
 
194
elif cmd == 'updatePincode':
195
  if len(args) != 5:
196
    print 'updatePincode requires 5 args'
197
    sys.exit(1)
198
  pp.pprint(client.updatePincode(eval(args[0]),args[1],eval(args[2]),eval(args[3]),eval(args[4]),))
199
 
3431 rajveer 200
else:
201
  print 'Unrecognized method %s' % cmd
202
  sys.exit(1)
203
 
412 ashish 204
transport.close()