Subversion Repositories SmartDukaan

Rev

Rev 11801 | Go to most recent revision | 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()'
35
  print '  void fulfillPO(i64 purchaseOrderId, i64 itemId, i64 quantity)'
36
  print '  void updatePurchaseOrder(PurchaseOrder purchaseOrder)'
5185 mandeep.dh 37
  print '  void unFulfillPO(i64 purchaseId, i64 itemId, i64 quantity)'
5443 mandeep.dh 38
  print '   getInvoices(i64 date)'
7410 amar.kumar 39
  print '   getInvoicesForWarehouse(i64 warehouseId, i64 supplierId, i64 date)'
5443 mandeep.dh 40
  print '  void createInvoice(Invoice invoice)'
5591 mandeep.dh 41
  print '  Supplier addSupplier(Supplier supplier)'
42
  print '  void updateSupplier(Supplier supplier)'
6762 amar.kumar 43
  print '  i64 createPurchaseReturn(PurchaseReturn purchaseReturn)'
44
  print '  void settlePurchaseReturn(i64 id)'
45
  print '   getUnsettledPurchaseReturns()'
46
  print '   getInvoice(string invoiceNumber, i64 supplierId)'
7672 rajveer 47
  print '  i64 createPurchaseForOurExtBilling(string invoiceNumber, double unitPrice, double nlc, i64 itemId)'
6762 amar.kumar 48
  print '  void fulfillPOForExtBilling(i64 itemId, i64 quantity)'
7410 amar.kumar 49
  print '  void closePO(i64 poId)'
50
  print '  bool isInvoiceReceived(string invoiceNumber, i64 supplierId)'
10864 manish.sha 51
  print '  void changeWarehouseForPO(i64 id, i64 warehouseId)'
52
  print '  void changePOStatus(i64 id, POStatus poStatus)'
11751 manish.sha 53
  print '  PurchaseReturn getPurchaseReturn(i64 id)'
13600 manish.sha 54
  print '  bool markPurchasereturnSettled(i64 id, SettlementType settlementType, string documentNumber, string settlementBy, i64 settledAmount)'
55
  print '   getPrSettlementsForPurchaseReturn(i64 purchaseReturnId)'
56
  print '  void updatePurchaseReturn(PurchaseReturn purchaseReturn)'
4502 mandeep.dh 57
  print ''
58
  sys.exit(0)
59
 
60
pp = pprint.PrettyPrinter(indent = 2)
61
host = 'localhost'
62
port = 9090
63
uri = ''
64
framed = False
65
http = False
66
argi = 1
67
 
68
if sys.argv[argi] == '-h':
69
  parts = sys.argv[argi+1].split(':')
70
  host = parts[0]
71
  port = int(parts[1])
72
  argi += 2
73
 
74
if sys.argv[argi] == '-u':
75
  url = urlparse(sys.argv[argi+1])
76
  parts = url[1].split(':')
77
  host = parts[0]
78
  if len(parts) > 1:
79
    port = int(parts[1])
80
  else:
81
    port = 80
82
  uri = url[2]
83
  if url[4]:
84
    uri += '?%s' % url[4]
85
  http = True
86
  argi += 2
87
 
88
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
89
  framed = True
90
  argi += 1
91
 
92
cmd = sys.argv[argi]
93
args = sys.argv[argi+1:]
94
 
95
if http:
96
  transport = THttpClient.THttpClient(host, port, uri)
97
else:
98
  socket = TSocket.TSocket(host, port)
99
  if framed:
100
    transport = TTransport.TFramedTransport(socket)
101
  else:
102
    transport = TTransport.TBufferedTransport(socket)
103
protocol = TBinaryProtocol.TBinaryProtocol(transport)
104
client = PurchaseService.Client(protocol)
105
transport.open()
106
 
107
if cmd == 'createPurchaseOrder':
108
  if len(args) != 1:
109
    print 'createPurchaseOrder requires 1 args'
110
    sys.exit(1)
111
  pp.pprint(client.createPurchaseOrder(eval(args[0]),))
112
 
113
elif cmd == 'getPurchaseOrder':
114
  if len(args) != 1:
115
    print 'getPurchaseOrder requires 1 args'
116
    sys.exit(1)
117
  pp.pprint(client.getPurchaseOrder(eval(args[0]),))
118
 
119
elif cmd == 'getAllPurchaseOrders':
120
  if len(args) != 1:
121
    print 'getAllPurchaseOrders requires 1 args'
122
    sys.exit(1)
123
  pp.pprint(client.getAllPurchaseOrders(eval(args[0]),))
124
 
125
elif cmd == 'getSupplier':
126
  if len(args) != 1:
127
    print 'getSupplier requires 1 args'
128
    sys.exit(1)
129
  pp.pprint(client.getSupplier(eval(args[0]),))
130
 
131
elif cmd == 'startPurchase':
11801 manish.sha 132
  if len(args) != 4:
133
    print 'startPurchase requires 4 args'
4502 mandeep.dh 134
    sys.exit(1)
11801 manish.sha 135
  pp.pprint(client.startPurchase(eval(args[0]),args[1],eval(args[2]),args[3],))
4502 mandeep.dh 136
 
137
elif cmd == 'closePurchase':
138
  if len(args) != 1:
139
    print 'closePurchase requires 1 args'
140
    sys.exit(1)
141
  pp.pprint(client.closePurchase(eval(args[0]),))
142
 
143
elif cmd == 'getAllPurchases':
144
  if len(args) != 2:
145
    print 'getAllPurchases requires 2 args'
146
    sys.exit(1)
147
  pp.pprint(client.getAllPurchases(eval(args[0]),eval(args[1]),))
148
 
6762 amar.kumar 149
elif cmd == 'getPurchasesForPO':
150
  if len(args) != 1:
151
    print 'getPurchasesForPO requires 1 args'
152
    sys.exit(1)
153
  pp.pprint(client.getPurchasesForPO(eval(args[0]),))
154
 
4555 mandeep.dh 155
elif cmd == 'getPurchaseOrderForPurchase':
156
  if len(args) != 1:
157
    print 'getPurchaseOrderForPurchase requires 1 args'
4502 mandeep.dh 158
    sys.exit(1)
4555 mandeep.dh 159
  pp.pprint(client.getPurchaseOrderForPurchase(eval(args[0]),))
4502 mandeep.dh 160
 
4754 mandeep.dh 161
elif cmd == 'getPendingPurchaseOrders':
162
  if len(args) != 1:
163
    print 'getPendingPurchaseOrders requires 1 args'
164
    sys.exit(1)
165
  pp.pprint(client.getPendingPurchaseOrders(eval(args[0]),))
166
 
167
elif cmd == 'getSuppliers':
168
  if len(args) != 0:
169
    print 'getSuppliers requires 0 args'
170
    sys.exit(1)
171
  pp.pprint(client.getSuppliers())
172
 
173
elif cmd == 'fulfillPO':
174
  if len(args) != 3:
175
    print 'fulfillPO requires 3 args'
176
    sys.exit(1)
177
  pp.pprint(client.fulfillPO(eval(args[0]),eval(args[1]),eval(args[2]),))
178
 
179
elif cmd == 'updatePurchaseOrder':
180
  if len(args) != 1:
181
    print 'updatePurchaseOrder requires 1 args'
182
    sys.exit(1)
183
  pp.pprint(client.updatePurchaseOrder(eval(args[0]),))
184
 
5185 mandeep.dh 185
elif cmd == 'unFulfillPO':
186
  if len(args) != 3:
187
    print 'unFulfillPO requires 3 args'
188
    sys.exit(1)
189
  pp.pprint(client.unFulfillPO(eval(args[0]),eval(args[1]),eval(args[2]),))
190
 
5443 mandeep.dh 191
elif cmd == 'getInvoices':
192
  if len(args) != 1:
193
    print 'getInvoices requires 1 args'
194
    sys.exit(1)
195
  pp.pprint(client.getInvoices(eval(args[0]),))
196
 
7410 amar.kumar 197
elif cmd == 'getInvoicesForWarehouse':
198
  if len(args) != 3:
199
    print 'getInvoicesForWarehouse requires 3 args'
200
    sys.exit(1)
201
  pp.pprint(client.getInvoicesForWarehouse(eval(args[0]),eval(args[1]),eval(args[2]),))
202
 
5443 mandeep.dh 203
elif cmd == 'createInvoice':
204
  if len(args) != 1:
205
    print 'createInvoice requires 1 args'
206
    sys.exit(1)
207
  pp.pprint(client.createInvoice(eval(args[0]),))
208
 
5591 mandeep.dh 209
elif cmd == 'addSupplier':
210
  if len(args) != 1:
211
    print 'addSupplier requires 1 args'
212
    sys.exit(1)
213
  pp.pprint(client.addSupplier(eval(args[0]),))
214
 
215
elif cmd == 'updateSupplier':
216
  if len(args) != 1:
217
    print 'updateSupplier requires 1 args'
218
    sys.exit(1)
219
  pp.pprint(client.updateSupplier(eval(args[0]),))
220
 
6762 amar.kumar 221
elif cmd == 'createPurchaseReturn':
222
  if len(args) != 1:
223
    print 'createPurchaseReturn requires 1 args'
224
    sys.exit(1)
225
  pp.pprint(client.createPurchaseReturn(eval(args[0]),))
226
 
227
elif cmd == 'settlePurchaseReturn':
228
  if len(args) != 1:
229
    print 'settlePurchaseReturn requires 1 args'
230
    sys.exit(1)
231
  pp.pprint(client.settlePurchaseReturn(eval(args[0]),))
232
 
233
elif cmd == 'getUnsettledPurchaseReturns':
234
  if len(args) != 0:
235
    print 'getUnsettledPurchaseReturns requires 0 args'
236
    sys.exit(1)
237
  pp.pprint(client.getUnsettledPurchaseReturns())
238
 
239
elif cmd == 'getInvoice':
240
  if len(args) != 2:
241
    print 'getInvoice requires 2 args'
242
    sys.exit(1)
243
  pp.pprint(client.getInvoice(args[0],eval(args[1]),))
244
 
245
elif cmd == 'createPurchaseForOurExtBilling':
7672 rajveer 246
  if len(args) != 4:
247
    print 'createPurchaseForOurExtBilling requires 4 args'
6762 amar.kumar 248
    sys.exit(1)
7672 rajveer 249
  pp.pprint(client.createPurchaseForOurExtBilling(args[0],eval(args[1]),eval(args[2]),eval(args[3]),))
6762 amar.kumar 250
 
251
elif cmd == 'fulfillPOForExtBilling':
252
  if len(args) != 2:
253
    print 'fulfillPOForExtBilling requires 2 args'
254
    sys.exit(1)
255
  pp.pprint(client.fulfillPOForExtBilling(eval(args[0]),eval(args[1]),))
256
 
7410 amar.kumar 257
elif cmd == 'closePO':
258
  if len(args) != 1:
259
    print 'closePO requires 1 args'
260
    sys.exit(1)
261
  pp.pprint(client.closePO(eval(args[0]),))
262
 
263
elif cmd == 'isInvoiceReceived':
264
  if len(args) != 2:
265
    print 'isInvoiceReceived requires 2 args'
266
    sys.exit(1)
267
  pp.pprint(client.isInvoiceReceived(args[0],eval(args[1]),))
268
 
10864 manish.sha 269
elif cmd == 'changeWarehouseForPO':
270
  if len(args) != 2:
271
    print 'changeWarehouseForPO requires 2 args'
272
    sys.exit(1)
273
  pp.pprint(client.changeWarehouseForPO(eval(args[0]),eval(args[1]),))
274
 
275
elif cmd == 'changePOStatus':
276
  if len(args) != 2:
277
    print 'changePOStatus requires 2 args'
278
    sys.exit(1)
279
  pp.pprint(client.changePOStatus(eval(args[0]),eval(args[1]),))
280
 
11751 manish.sha 281
elif cmd == 'getPurchaseReturn':
282
  if len(args) != 1:
283
    print 'getPurchaseReturn requires 1 args'
284
    sys.exit(1)
285
  pp.pprint(client.getPurchaseReturn(eval(args[0]),))
286
 
13600 manish.sha 287
elif cmd == 'markPurchasereturnSettled':
288
  if len(args) != 5:
289
    print 'markPurchasereturnSettled requires 5 args'
290
    sys.exit(1)
291
  pp.pprint(client.markPurchasereturnSettled(eval(args[0]),eval(args[1]),args[2],args[3],eval(args[4]),))
292
 
293
elif cmd == 'getPrSettlementsForPurchaseReturn':
294
  if len(args) != 1:
295
    print 'getPrSettlementsForPurchaseReturn requires 1 args'
296
    sys.exit(1)
297
  pp.pprint(client.getPrSettlementsForPurchaseReturn(eval(args[0]),))
298
 
299
elif cmd == 'updatePurchaseReturn':
300
  if len(args) != 1:
301
    print 'updatePurchaseReturn requires 1 args'
302
    sys.exit(1)
303
  pp.pprint(client.updatePurchaseReturn(eval(args[0]),))
304
 
4502 mandeep.dh 305
else:
306
  print 'Unrecognized method %s' % cmd
307
  sys.exit(1)
308
 
309
transport.close()