Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
5944 mandeep.dh 1
#!/usr/bin/env python
2
#
3
# Autogenerated by Thrift Compiler (0.7.0)
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 InventoryService
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:'
24
  print '  i64 addWarehouse(Warehouse warehouse)'
25
  print '  i64 addVendor(Vendor vendor)'
26
  print '  void updateInventoryHistory(i64 warehouse_id, string timestamp,  availability)'
27
  print '  void updateInventory(i64 warehouse_id, string timestamp,  availability)'
28
  print '  void addInventory(i64 itemId, i64 warehouseId, i64 quantity)'
29
  print '  void retireWarehouse(i64 warehouse_id)'
30
  print '  ItemInventory getItemInventoryByItemId(i64 item_id)'
31
  print '  i64 getItemAvailibilityAtWarehouse(i64 warehouse_id, i64 item_id)'
5978 rajveer 32
  print '   getItemAvailabilityAtLocation(i64 itemId, i64 sourceId)'
5944 mandeep.dh 33
  print '   getAllWarehouses(bool isActive)'
34
  print '  Warehouse getWarehouse(i64 warehouse_id)'
35
  print '   getAllItemsForWarehouse(i64 warehouse_id)'
5966 rajveer 36
  print '  bool isOrderBillable(i64 itemId, i64 warehouseId, i64 sourceId, i64 orderId)'
37
  print '  bool reserveItemInWarehouse(i64 itemId, i64 warehouseId, i64 sourceId, i64 orderId, i64 createdTimestamp, i64 promisedShippingTimestamp, double quantity)'
38
  print '  bool reduceReservationCount(i64 itemId, i64 warehouseId, i64 sourceId, i64 orderId, double quantity)'
5944 mandeep.dh 39
  print '  VendorItemPricing getItemPricing(i64 itemId, i64 vendorId)'
40
  print '   getAllItemPricing(i64 itemId)'
41
  print '  void addVendorItemPricing(VendorItemPricing vendorItemPricing)'
42
  print '  Vendor getVendor(i64 vendorId)'
43
  print '   getAllVendors()'
44
  print '  void addVendorItemMapping(string key, VendorItemMapping vendorItemMapping)'
45
  print '   getVendorItemMappings(i64 itemId)'
46
  print '   getPendingOrdersInventory(i64 vendorid)'
47
  print '   getWarehouses(WarehouseType warehouseType, InventoryType inventoryType, i64 vendorId, i64 billingWarehouseId, i64 shippingWarehouseId)'
48
  print '  void resetAvailability(string itemKey, i64 vendorId, i64 quantity, i64 warehouseId)'
49
  print '  void resetAvailabilityForWarehouse(i64 warehouseId)'
50
  print '   getItemKeysToBeProcessed(i64 warehouseId)'
51
  print '  void markMissedInventoryUpdatesAsProcessed(string itemKey, i64 warehouseId)'
52
  print '   getIgnoredItemKeys()'
53
  print '  void addBadInventory(i64 itemId, i64 warehouseId, i64 quantity)'
54
  print '   getShippingLocations()'
55
  print '   getAllVendorItemMappings()'
56
  print '   getInventorySnapshot(i64 warehouseId)'
57
  print '  void clearItemAvailabilityCache()'
58
  print '  void updateVendorString(i64 warehouseId, string vendorString)'
59
  print ''
60
  sys.exit(0)
61
 
62
pp = pprint.PrettyPrinter(indent = 2)
63
host = 'localhost'
64
port = 9090
65
uri = ''
66
framed = False
67
http = False
68
argi = 1
69
 
70
if sys.argv[argi] == '-h':
71
  parts = sys.argv[argi+1].split(':')
72
  host = parts[0]
73
  port = int(parts[1])
74
  argi += 2
75
 
76
if sys.argv[argi] == '-u':
77
  url = urlparse(sys.argv[argi+1])
78
  parts = url[1].split(':')
79
  host = parts[0]
80
  if len(parts) > 1:
81
    port = int(parts[1])
82
  else:
83
    port = 80
84
  uri = url[2]
85
  if url[4]:
86
    uri += '?%s' % url[4]
87
  http = True
88
  argi += 2
89
 
90
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
91
  framed = True
92
  argi += 1
93
 
94
cmd = sys.argv[argi]
95
args = sys.argv[argi+1:]
96
 
97
if http:
98
  transport = THttpClient.THttpClient(host, port, uri)
99
else:
100
  socket = TSocket.TSocket(host, port)
101
  if framed:
102
    transport = TTransport.TFramedTransport(socket)
103
  else:
104
    transport = TTransport.TBufferedTransport(socket)
105
protocol = TBinaryProtocol.TBinaryProtocol(transport)
106
client = InventoryService.Client(protocol)
107
transport.open()
108
 
109
if cmd == 'addWarehouse':
110
  if len(args) != 1:
111
    print 'addWarehouse requires 1 args'
112
    sys.exit(1)
113
  pp.pprint(client.addWarehouse(eval(args[0]),))
114
 
115
elif cmd == 'addVendor':
116
  if len(args) != 1:
117
    print 'addVendor requires 1 args'
118
    sys.exit(1)
119
  pp.pprint(client.addVendor(eval(args[0]),))
120
 
121
elif cmd == 'updateInventoryHistory':
122
  if len(args) != 3:
123
    print 'updateInventoryHistory requires 3 args'
124
    sys.exit(1)
125
  pp.pprint(client.updateInventoryHistory(eval(args[0]),args[1],eval(args[2]),))
126
 
127
elif cmd == 'updateInventory':
128
  if len(args) != 3:
129
    print 'updateInventory requires 3 args'
130
    sys.exit(1)
131
  pp.pprint(client.updateInventory(eval(args[0]),args[1],eval(args[2]),))
132
 
133
elif cmd == 'addInventory':
134
  if len(args) != 3:
135
    print 'addInventory requires 3 args'
136
    sys.exit(1)
137
  pp.pprint(client.addInventory(eval(args[0]),eval(args[1]),eval(args[2]),))
138
 
139
elif cmd == 'retireWarehouse':
140
  if len(args) != 1:
141
    print 'retireWarehouse requires 1 args'
142
    sys.exit(1)
143
  pp.pprint(client.retireWarehouse(eval(args[0]),))
144
 
145
elif cmd == 'getItemInventoryByItemId':
146
  if len(args) != 1:
147
    print 'getItemInventoryByItemId requires 1 args'
148
    sys.exit(1)
149
  pp.pprint(client.getItemInventoryByItemId(eval(args[0]),))
150
 
151
elif cmd == 'getItemAvailibilityAtWarehouse':
152
  if len(args) != 2:
153
    print 'getItemAvailibilityAtWarehouse requires 2 args'
154
    sys.exit(1)
155
  pp.pprint(client.getItemAvailibilityAtWarehouse(eval(args[0]),eval(args[1]),))
156
 
157
elif cmd == 'getItemAvailabilityAtLocation':
5978 rajveer 158
  if len(args) != 2:
159
    print 'getItemAvailabilityAtLocation requires 2 args'
5944 mandeep.dh 160
    sys.exit(1)
5978 rajveer 161
  pp.pprint(client.getItemAvailabilityAtLocation(eval(args[0]),eval(args[1]),))
5944 mandeep.dh 162
 
163
elif cmd == 'getAllWarehouses':
164
  if len(args) != 1:
165
    print 'getAllWarehouses requires 1 args'
166
    sys.exit(1)
167
  pp.pprint(client.getAllWarehouses(eval(args[0]),))
168
 
169
elif cmd == 'getWarehouse':
170
  if len(args) != 1:
171
    print 'getWarehouse requires 1 args'
172
    sys.exit(1)
173
  pp.pprint(client.getWarehouse(eval(args[0]),))
174
 
175
elif cmd == 'getAllItemsForWarehouse':
176
  if len(args) != 1:
177
    print 'getAllItemsForWarehouse requires 1 args'
178
    sys.exit(1)
179
  pp.pprint(client.getAllItemsForWarehouse(eval(args[0]),))
180
 
5966 rajveer 181
elif cmd == 'isOrderBillable':
182
  if len(args) != 4:
183
    print 'isOrderBillable requires 4 args'
184
    sys.exit(1)
185
  pp.pprint(client.isOrderBillable(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
186
 
5944 mandeep.dh 187
elif cmd == 'reserveItemInWarehouse':
5966 rajveer 188
  if len(args) != 7:
189
    print 'reserveItemInWarehouse requires 7 args'
5944 mandeep.dh 190
    sys.exit(1)
5966 rajveer 191
  pp.pprint(client.reserveItemInWarehouse(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),eval(args[5]),eval(args[6]),))
5944 mandeep.dh 192
 
193
elif cmd == 'reduceReservationCount':
5966 rajveer 194
  if len(args) != 5:
195
    print 'reduceReservationCount requires 5 args'
5944 mandeep.dh 196
    sys.exit(1)
5966 rajveer 197
  pp.pprint(client.reduceReservationCount(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))
5944 mandeep.dh 198
 
199
elif cmd == 'getItemPricing':
200
  if len(args) != 2:
201
    print 'getItemPricing requires 2 args'
202
    sys.exit(1)
203
  pp.pprint(client.getItemPricing(eval(args[0]),eval(args[1]),))
204
 
205
elif cmd == 'getAllItemPricing':
206
  if len(args) != 1:
207
    print 'getAllItemPricing requires 1 args'
208
    sys.exit(1)
209
  pp.pprint(client.getAllItemPricing(eval(args[0]),))
210
 
211
elif cmd == 'addVendorItemPricing':
212
  if len(args) != 1:
213
    print 'addVendorItemPricing requires 1 args'
214
    sys.exit(1)
215
  pp.pprint(client.addVendorItemPricing(eval(args[0]),))
216
 
217
elif cmd == 'getVendor':
218
  if len(args) != 1:
219
    print 'getVendor requires 1 args'
220
    sys.exit(1)
221
  pp.pprint(client.getVendor(eval(args[0]),))
222
 
223
elif cmd == 'getAllVendors':
224
  if len(args) != 0:
225
    print 'getAllVendors requires 0 args'
226
    sys.exit(1)
227
  pp.pprint(client.getAllVendors())
228
 
229
elif cmd == 'addVendorItemMapping':
230
  if len(args) != 2:
231
    print 'addVendorItemMapping requires 2 args'
232
    sys.exit(1)
233
  pp.pprint(client.addVendorItemMapping(args[0],eval(args[1]),))
234
 
235
elif cmd == 'getVendorItemMappings':
236
  if len(args) != 1:
237
    print 'getVendorItemMappings requires 1 args'
238
    sys.exit(1)
239
  pp.pprint(client.getVendorItemMappings(eval(args[0]),))
240
 
241
elif cmd == 'getPendingOrdersInventory':
242
  if len(args) != 1:
243
    print 'getPendingOrdersInventory requires 1 args'
244
    sys.exit(1)
245
  pp.pprint(client.getPendingOrdersInventory(eval(args[0]),))
246
 
247
elif cmd == 'getWarehouses':
248
  if len(args) != 5:
249
    print 'getWarehouses requires 5 args'
250
    sys.exit(1)
251
  pp.pprint(client.getWarehouses(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))
252
 
253
elif cmd == 'resetAvailability':
254
  if len(args) != 4:
255
    print 'resetAvailability requires 4 args'
256
    sys.exit(1)
257
  pp.pprint(client.resetAvailability(args[0],eval(args[1]),eval(args[2]),eval(args[3]),))
258
 
259
elif cmd == 'resetAvailabilityForWarehouse':
260
  if len(args) != 1:
261
    print 'resetAvailabilityForWarehouse requires 1 args'
262
    sys.exit(1)
263
  pp.pprint(client.resetAvailabilityForWarehouse(eval(args[0]),))
264
 
265
elif cmd == 'getItemKeysToBeProcessed':
266
  if len(args) != 1:
267
    print 'getItemKeysToBeProcessed requires 1 args'
268
    sys.exit(1)
269
  pp.pprint(client.getItemKeysToBeProcessed(eval(args[0]),))
270
 
271
elif cmd == 'markMissedInventoryUpdatesAsProcessed':
272
  if len(args) != 2:
273
    print 'markMissedInventoryUpdatesAsProcessed requires 2 args'
274
    sys.exit(1)
275
  pp.pprint(client.markMissedInventoryUpdatesAsProcessed(args[0],eval(args[1]),))
276
 
277
elif cmd == 'getIgnoredItemKeys':
278
  if len(args) != 0:
279
    print 'getIgnoredItemKeys requires 0 args'
280
    sys.exit(1)
281
  pp.pprint(client.getIgnoredItemKeys())
282
 
283
elif cmd == 'addBadInventory':
284
  if len(args) != 3:
285
    print 'addBadInventory requires 3 args'
286
    sys.exit(1)
287
  pp.pprint(client.addBadInventory(eval(args[0]),eval(args[1]),eval(args[2]),))
288
 
289
elif cmd == 'getShippingLocations':
290
  if len(args) != 0:
291
    print 'getShippingLocations requires 0 args'
292
    sys.exit(1)
293
  pp.pprint(client.getShippingLocations())
294
 
295
elif cmd == 'getAllVendorItemMappings':
296
  if len(args) != 0:
297
    print 'getAllVendorItemMappings requires 0 args'
298
    sys.exit(1)
299
  pp.pprint(client.getAllVendorItemMappings())
300
 
301
elif cmd == 'getInventorySnapshot':
302
  if len(args) != 1:
303
    print 'getInventorySnapshot requires 1 args'
304
    sys.exit(1)
305
  pp.pprint(client.getInventorySnapshot(eval(args[0]),))
306
 
307
elif cmd == 'clearItemAvailabilityCache':
308
  if len(args) != 0:
309
    print 'clearItemAvailabilityCache requires 0 args'
310
    sys.exit(1)
311
  pp.pprint(client.clearItemAvailabilityCache())
312
 
313
elif cmd == 'updateVendorString':
314
  if len(args) != 2:
315
    print 'updateVendorString requires 2 args'
316
    sys.exit(1)
317
  pp.pprint(client.updateVendorString(eval(args[0]),args[1],))
318
 
319
else:
320
  print 'Unrecognized method %s' % cmd
321
  sys.exit(1)
322
 
323
transport.close()