Subversion Repositories SmartDukaan

Rev

Rev 1610 | Rev 2025 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
349 ashish 1
#!/usr/bin/env python
2
#
3
# Autogenerated by Thrift
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 HelperService
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:'
765 rajveer 24
  print '  void closeSession()'
1395 varun.gupt 25
  print '  void saveUserEmailForSending(string emailTo, string emailFrom, string subject, string body, string source, string emailType)'
1422 varun.gupt 26
  print '   getEmailsToBeSent(string emailType)'
27
  print '  void markEmailAsSent(i64 emailId)'
349 ashish 28
  print '  void sendMail(Mail mail)'
29
  print '  void sendText(TextMessage message)'
30
  print '  void addMessage(Message message)'
31
  print '  void updateMessage(i64 id, string message)'
353 ashish 32
  print '  Message getMessage(i64 id)'
33
  print '  Message getSubstitutedMessage(i64 id,  params)'
494 rajveer 34
  print '  bool addUser(string username, string password, i64 warehouseId)'
35
  print '  bool deleteUser(string username)'
36
  print '  i64 authenticateUser(string username, string password)'
37
  print '  bool updatePassword(string username, string oldPassword, string newPassword)'
759 chandransh 38
  print '  LogisticsUser authenticateLogisticsUser(string username, string password)'
1610 ankur.sing 39
  print '  StatisticsUser authenticateStatisticsUser(string username, string password)'
1891 ankur.sing 40
  print '  ReportUser authenticateReportUser(string username, string password)'
41
  print '   getReports(i64 role)'
349 ashish 42
  print ''
43
  sys.exit(0)
44
 
45
pp = pprint.PrettyPrinter(indent = 2)
46
host = 'localhost'
47
port = 9090
48
uri = ''
49
framed = False
50
http = False
51
argi = 1
52
 
53
if sys.argv[argi] == '-h':
54
  parts = sys.argv[argi+1].split(':') 
55
  host = parts[0]
56
  port = int(parts[1])
57
  argi += 2
58
 
59
if sys.argv[argi] == '-u':
60
  url = urlparse(sys.argv[argi+1])
61
  parts = url[1].split(':') 
62
  host = parts[0]
63
  if len(parts) > 1:
64
    port = int(parts[1])
65
  else:
66
    port = 80
67
  uri = url[2]
68
  http = True
69
  argi += 2
70
 
71
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
72
  framed = True
73
  argi += 1
74
 
75
cmd = sys.argv[argi]
76
args = sys.argv[argi+1:]
77
 
78
if http:
79
  transport = THttpClient.THttpClient(host, port, uri)
80
else:
81
  socket = TSocket.TSocket(host, port)
82
  if framed:
83
    transport = TTransport.TFramedTransport(socket)
84
  else:
85
    transport = TTransport.TBufferedTransport(socket)
86
protocol = TBinaryProtocol.TBinaryProtocol(transport)
87
client = HelperService.Client(protocol)
88
transport.open()
89
 
765 rajveer 90
if cmd == 'closeSession':
91
  if len(args) != 0:
92
    print 'closeSession requires 0 args'
93
    sys.exit(1)
94
  pp.pprint(client.closeSession())
95
 
1395 varun.gupt 96
elif cmd == 'saveUserEmailForSending':
97
  if len(args) != 6:
98
    print 'saveUserEmailForSending requires 6 args'
99
    sys.exit(1)
100
  pp.pprint(client.saveUserEmailForSending(args[0],args[1],args[2],args[3],args[4],args[5],))
101
 
1422 varun.gupt 102
elif cmd == 'getEmailsToBeSent':
103
  if len(args) != 1:
104
    print 'getEmailsToBeSent requires 1 args'
105
    sys.exit(1)
106
  pp.pprint(client.getEmailsToBeSent(args[0],))
107
 
108
elif cmd == 'markEmailAsSent':
109
  if len(args) != 1:
110
    print 'markEmailAsSent requires 1 args'
111
    sys.exit(1)
112
  pp.pprint(client.markEmailAsSent(eval(args[0]),))
113
 
765 rajveer 114
elif cmd == 'sendMail':
349 ashish 115
  if len(args) != 1:
116
    print 'sendMail requires 1 args'
117
    sys.exit(1)
118
  pp.pprint(client.sendMail(eval(args[0]),))
119
 
120
elif cmd == 'sendText':
121
  if len(args) != 1:
122
    print 'sendText requires 1 args'
123
    sys.exit(1)
124
  pp.pprint(client.sendText(eval(args[0]),))
125
 
126
elif cmd == 'addMessage':
127
  if len(args) != 1:
128
    print 'addMessage requires 1 args'
129
    sys.exit(1)
130
  pp.pprint(client.addMessage(eval(args[0]),))
131
 
132
elif cmd == 'updateMessage':
133
  if len(args) != 2:
134
    print 'updateMessage requires 2 args'
135
    sys.exit(1)
136
  pp.pprint(client.updateMessage(eval(args[0]),args[1],))
137
 
138
elif cmd == 'getMessage':
139
  if len(args) != 1:
140
    print 'getMessage requires 1 args'
141
    sys.exit(1)
142
  pp.pprint(client.getMessage(eval(args[0]),))
143
 
144
elif cmd == 'getSubstitutedMessage':
145
  if len(args) != 2:
146
    print 'getSubstitutedMessage requires 2 args'
147
    sys.exit(1)
148
  pp.pprint(client.getSubstitutedMessage(eval(args[0]),eval(args[1]),))
149
 
494 rajveer 150
elif cmd == 'addUser':
151
  if len(args) != 3:
152
    print 'addUser requires 3 args'
153
    sys.exit(1)
154
  pp.pprint(client.addUser(args[0],args[1],eval(args[2]),))
155
 
156
elif cmd == 'deleteUser':
157
  if len(args) != 1:
158
    print 'deleteUser requires 1 args'
159
    sys.exit(1)
160
  pp.pprint(client.deleteUser(args[0],))
161
 
162
elif cmd == 'authenticateUser':
163
  if len(args) != 2:
164
    print 'authenticateUser requires 2 args'
165
    sys.exit(1)
166
  pp.pprint(client.authenticateUser(args[0],args[1],))
167
 
168
elif cmd == 'updatePassword':
169
  if len(args) != 3:
170
    print 'updatePassword requires 3 args'
171
    sys.exit(1)
172
  pp.pprint(client.updatePassword(args[0],args[1],args[2],))
173
 
759 chandransh 174
elif cmd == 'authenticateLogisticsUser':
175
  if len(args) != 2:
176
    print 'authenticateLogisticsUser requires 2 args'
177
    sys.exit(1)
178
  pp.pprint(client.authenticateLogisticsUser(args[0],args[1],))
179
 
1610 ankur.sing 180
elif cmd == 'authenticateStatisticsUser':
181
  if len(args) != 2:
182
    print 'authenticateStatisticsUser requires 2 args'
183
    sys.exit(1)
184
  pp.pprint(client.authenticateStatisticsUser(args[0],args[1],))
185
 
1891 ankur.sing 186
elif cmd == 'authenticateReportUser':
187
  if len(args) != 2:
188
    print 'authenticateReportUser requires 2 args'
189
    sys.exit(1)
190
  pp.pprint(client.authenticateReportUser(args[0],args[1],))
191
 
192
elif cmd == 'getReports':
193
  if len(args) != 1:
194
    print 'getReports requires 1 args'
195
    sys.exit(1)
196
  pp.pprint(client.getReports(eval(args[0]),))
197
 
349 ashish 198
transport.close()