Subversion Repositories SmartDukaan

Rev

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