Subversion Repositories SmartDukaan

Rev

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