Subversion Repositories SmartDukaan

Rev

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