Subversion Repositories SmartDukaan

Rev

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