Subversion Repositories SmartDukaan

Rev

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