Subversion Repositories SmartDukaan

Rev

Rev 13600 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4502 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 PurchaseService
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 createPurchaseOrder(PurchaseOrder purchaseOrder)'
25
  print '  PurchaseOrder getPurchaseOrder(i64 id)'
26
  print '   getAllPurchaseOrders(POStatus status)'
27
  print '  Supplier getSupplier(i64 id)'
11801 manish.sha 28
  print '  i64 startPurchase(i64 purchaseOrderId, string invoiceNumber, double freightCharges, string purchaseComments)'
4502 mandeep.dh 29
  print '  i64 closePurchase(i64 purchaseId)'
30
  print '   getAllPurchases(i64 purchaseOrderId, bool open)'
6762 amar.kumar 31
  print '   getPurchasesForPO(i64 purchaseOrderId)'
4555 mandeep.dh 32
  print '  PurchaseOrder getPurchaseOrderForPurchase(i64 purchaseId)'
4754 mandeep.dh 33
  print '   getPendingPurchaseOrders(i64 warehouseId)'
34
  print '   getSuppliers()'
21847 amit.gupta 35
  print '   getAllSuppliers()'
4754 mandeep.dh 36
  print '  void fulfillPO(i64 purchaseOrderId, i64 itemId, i64 quantity)'
37
  print '  void updatePurchaseOrder(PurchaseOrder purchaseOrder)'
5185 mandeep.dh 38
  print '  void unFulfillPO(i64 purchaseId, i64 itemId, i64 quantity)'
5443 mandeep.dh 39
  print '   getInvoices(i64 date)'
7410 amar.kumar 40
  print '   getInvoicesForWarehouse(i64 warehouseId, i64 supplierId, i64 date)'
5443 mandeep.dh 41
  print '  void createInvoice(Invoice invoice)'
5591 mandeep.dh 42
  print '  Supplier addSupplier(Supplier supplier)'
43
  print '  void updateSupplier(Supplier supplier)'
6762 amar.kumar 44
  print '  i64 createPurchaseReturn(PurchaseReturn purchaseReturn)'
45
  print '  void settlePurchaseReturn(i64 id)'
46
  print '   getUnsettledPurchaseReturns()'
47
  print '   getInvoice(string invoiceNumber, i64 supplierId)'
7672 rajveer 48
  print '  i64 createPurchaseForOurExtBilling(string invoiceNumber, double unitPrice, double nlc, i64 itemId)'
6762 amar.kumar 49
  print '  void fulfillPOForExtBilling(i64 itemId, i64 quantity)'
7410 amar.kumar 50
  print '  void closePO(i64 poId)'
51
  print '  bool isInvoiceReceived(string invoiceNumber, i64 supplierId)'
10864 manish.sha 52
  print '  void changeWarehouseForPO(i64 id, i64 warehouseId)'
53
  print '  void changePOStatus(i64 id, POStatus poStatus)'
11751 manish.sha 54
  print '  PurchaseReturn getPurchaseReturn(i64 id)'
13600 manish.sha 55
  print '  bool markPurchasereturnSettled(i64 id, SettlementType settlementType, string documentNumber, string settlementBy, i64 settledAmount)'
56
  print '   getPrSettlementsForPurchaseReturn(i64 purchaseReturnId)'
57
  print '  void updatePurchaseReturn(PurchaseReturn purchaseReturn)'
4502 mandeep.dh 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 = PurchaseService.Client(protocol)
106
transport.open()
107
 
108
if cmd == 'createPurchaseOrder':
109
  if len(args) != 1:
110
    print 'createPurchaseOrder requires 1 args'
111
    sys.exit(1)
112
  pp.pprint(client.createPurchaseOrder(eval(args[0]),))
113
 
114
elif cmd == 'getPurchaseOrder':
115
  if len(args) != 1:
116
    print 'getPurchaseOrder requires 1 args'
117
    sys.exit(1)
118
  pp.pprint(client.getPurchaseOrder(eval(args[0]),))
119
 
120
elif cmd == 'getAllPurchaseOrders':
121
  if len(args) != 1:
122
    print 'getAllPurchaseOrders requires 1 args'
123
    sys.exit(1)
124
  pp.pprint(client.getAllPurchaseOrders(eval(args[0]),))
125
 
126
elif cmd == 'getSupplier':
127
  if len(args) != 1:
128
    print 'getSupplier requires 1 args'
129
    sys.exit(1)
130
  pp.pprint(client.getSupplier(eval(args[0]),))
131
 
132
elif cmd == 'startPurchase':
11801 manish.sha 133
  if len(args) != 4:
134
    print 'startPurchase requires 4 args'
4502 mandeep.dh 135
    sys.exit(1)
11801 manish.sha 136
  pp.pprint(client.startPurchase(eval(args[0]),args[1],eval(args[2]),args[3],))
4502 mandeep.dh 137
 
138
elif cmd == 'closePurchase':
139
  if len(args) != 1:
140
    print 'closePurchase requires 1 args'
141
    sys.exit(1)
142
  pp.pprint(client.closePurchase(eval(args[0]),))
143
 
144
elif cmd == 'getAllPurchases':
145
  if len(args) != 2:
146
    print 'getAllPurchases requires 2 args'
147
    sys.exit(1)
148
  pp.pprint(client.getAllPurchases(eval(args[0]),eval(args[1]),))
149
 
6762 amar.kumar 150
elif cmd == 'getPurchasesForPO':
151
  if len(args) != 1:
152
    print 'getPurchasesForPO requires 1 args'
153
    sys.exit(1)
154
  pp.pprint(client.getPurchasesForPO(eval(args[0]),))
155
 
4555 mandeep.dh 156
elif cmd == 'getPurchaseOrderForPurchase':
157
  if len(args) != 1:
158
    print 'getPurchaseOrderForPurchase requires 1 args'
4502 mandeep.dh 159
    sys.exit(1)
4555 mandeep.dh 160
  pp.pprint(client.getPurchaseOrderForPurchase(eval(args[0]),))
4502 mandeep.dh 161
 
4754 mandeep.dh 162
elif cmd == 'getPendingPurchaseOrders':
163
  if len(args) != 1:
164
    print 'getPendingPurchaseOrders requires 1 args'
165
    sys.exit(1)
166
  pp.pprint(client.getPendingPurchaseOrders(eval(args[0]),))
167
 
168
elif cmd == 'getSuppliers':
169
  if len(args) != 0:
170
    print 'getSuppliers requires 0 args'
171
    sys.exit(1)
172
  pp.pprint(client.getSuppliers())
173
 
21847 amit.gupta 174
elif cmd == 'getAllSuppliers':
175
  if len(args) != 0:
176
    print 'getAllSuppliers requires 0 args'
177
    sys.exit(1)
178
  pp.pprint(client.getAllSuppliers())
179
 
4754 mandeep.dh 180
elif cmd == 'fulfillPO':
181
  if len(args) != 3:
182
    print 'fulfillPO requires 3 args'
183
    sys.exit(1)
184
  pp.pprint(client.fulfillPO(eval(args[0]),eval(args[1]),eval(args[2]),))
185
 
186
elif cmd == 'updatePurchaseOrder':
187
  if len(args) != 1:
188
    print 'updatePurchaseOrder requires 1 args'
189
    sys.exit(1)
190
  pp.pprint(client.updatePurchaseOrder(eval(args[0]),))
191
 
5185 mandeep.dh 192
elif cmd == 'unFulfillPO':
193
  if len(args) != 3:
194
    print 'unFulfillPO requires 3 args'
195
    sys.exit(1)
196
  pp.pprint(client.unFulfillPO(eval(args[0]),eval(args[1]),eval(args[2]),))
197
 
5443 mandeep.dh 198
elif cmd == 'getInvoices':
199
  if len(args) != 1:
200
    print 'getInvoices requires 1 args'
201
    sys.exit(1)
202
  pp.pprint(client.getInvoices(eval(args[0]),))
203
 
7410 amar.kumar 204
elif cmd == 'getInvoicesForWarehouse':
205
  if len(args) != 3:
206
    print 'getInvoicesForWarehouse requires 3 args'
207
    sys.exit(1)
208
  pp.pprint(client.getInvoicesForWarehouse(eval(args[0]),eval(args[1]),eval(args[2]),))
209
 
5443 mandeep.dh 210
elif cmd == 'createInvoice':
211
  if len(args) != 1:
212
    print 'createInvoice requires 1 args'
213
    sys.exit(1)
214
  pp.pprint(client.createInvoice(eval(args[0]),))
215
 
5591 mandeep.dh 216
elif cmd == 'addSupplier':
217
  if len(args) != 1:
218
    print 'addSupplier requires 1 args'
219
    sys.exit(1)
220
  pp.pprint(client.addSupplier(eval(args[0]),))
221
 
222
elif cmd == 'updateSupplier':
223
  if len(args) != 1:
224
    print 'updateSupplier requires 1 args'
225
    sys.exit(1)
226
  pp.pprint(client.updateSupplier(eval(args[0]),))
227
 
6762 amar.kumar 228
elif cmd == 'createPurchaseReturn':
229
  if len(args) != 1:
230
    print 'createPurchaseReturn requires 1 args'
231
    sys.exit(1)
232
  pp.pprint(client.createPurchaseReturn(eval(args[0]),))
233
 
234
elif cmd == 'settlePurchaseReturn':
235
  if len(args) != 1:
236
    print 'settlePurchaseReturn requires 1 args'
237
    sys.exit(1)
238
  pp.pprint(client.settlePurchaseReturn(eval(args[0]),))
239
 
240
elif cmd == 'getUnsettledPurchaseReturns':
241
  if len(args) != 0:
242
    print 'getUnsettledPurchaseReturns requires 0 args'
243
    sys.exit(1)
244
  pp.pprint(client.getUnsettledPurchaseReturns())
245
 
246
elif cmd == 'getInvoice':
247
  if len(args) != 2:
248
    print 'getInvoice requires 2 args'
249
    sys.exit(1)
250
  pp.pprint(client.getInvoice(args[0],eval(args[1]),))
251
 
252
elif cmd == 'createPurchaseForOurExtBilling':
7672 rajveer 253
  if len(args) != 4:
254
    print 'createPurchaseForOurExtBilling requires 4 args'
6762 amar.kumar 255
    sys.exit(1)
7672 rajveer 256
  pp.pprint(client.createPurchaseForOurExtBilling(args[0],eval(args[1]),eval(args[2]),eval(args[3]),))
6762 amar.kumar 257
 
258
elif cmd == 'fulfillPOForExtBilling':
259
  if len(args) != 2:
260
    print 'fulfillPOForExtBilling requires 2 args'
261
    sys.exit(1)
262
  pp.pprint(client.fulfillPOForExtBilling(eval(args[0]),eval(args[1]),))
263
 
7410 amar.kumar 264
elif cmd == 'closePO':
265
  if len(args) != 1:
266
    print 'closePO requires 1 args'
267
    sys.exit(1)
268
  pp.pprint(client.closePO(eval(args[0]),))
269
 
270
elif cmd == 'isInvoiceReceived':
271
  if len(args) != 2:
272
    print 'isInvoiceReceived requires 2 args'
273
    sys.exit(1)
274
  pp.pprint(client.isInvoiceReceived(args[0],eval(args[1]),))
275
 
10864 manish.sha 276
elif cmd == 'changeWarehouseForPO':
277
  if len(args) != 2:
278
    print 'changeWarehouseForPO requires 2 args'
279
    sys.exit(1)
280
  pp.pprint(client.changeWarehouseForPO(eval(args[0]),eval(args[1]),))
281
 
282
elif cmd == 'changePOStatus':
283
  if len(args) != 2:
284
    print 'changePOStatus requires 2 args'
285
    sys.exit(1)
286
  pp.pprint(client.changePOStatus(eval(args[0]),eval(args[1]),))
287
 
11751 manish.sha 288
elif cmd == 'getPurchaseReturn':
289
  if len(args) != 1:
290
    print 'getPurchaseReturn requires 1 args'
291
    sys.exit(1)
292
  pp.pprint(client.getPurchaseReturn(eval(args[0]),))
293
 
13600 manish.sha 294
elif cmd == 'markPurchasereturnSettled':
295
  if len(args) != 5:
296
    print 'markPurchasereturnSettled requires 5 args'
297
    sys.exit(1)
298
  pp.pprint(client.markPurchasereturnSettled(eval(args[0]),eval(args[1]),args[2],args[3],eval(args[4]),))
299
 
300
elif cmd == 'getPrSettlementsForPurchaseReturn':
301
  if len(args) != 1:
302
    print 'getPrSettlementsForPurchaseReturn requires 1 args'
303
    sys.exit(1)
304
  pp.pprint(client.getPrSettlementsForPurchaseReturn(eval(args[0]),))
305
 
306
elif cmd == 'updatePurchaseReturn':
307
  if len(args) != 1:
308
    print 'updatePurchaseReturn requires 1 args'
309
    sys.exit(1)
310
  pp.pprint(client.updatePurchaseReturn(eval(args[0]),))
311
 
4502 mandeep.dh 312
else:
313
  print 'Unrecognized method %s' % cmd
314
  sys.exit(1)
315
 
316
transport.close()