Subversion Repositories SmartDukaan

Rev

Rev 1395 | Rev 1610 | 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)'
349 ashish 39
  print ''
40
  sys.exit(0)
41
 
42
pp = pprint.PrettyPrinter(indent = 2)
43
host = 'localhost'
44
port = 9090
45
uri = ''
46
framed = False
47
http = False
48
argi = 1
49
 
50
if sys.argv[argi] == '-h':
51
  parts = sys.argv[argi+1].split(':') 
52
  host = parts[0]
53
  port = int(parts[1])
54
  argi += 2
55
 
56
if sys.argv[argi] == '-u':
57
  url = urlparse(sys.argv[argi+1])
58
  parts = url[1].split(':') 
59
  host = parts[0]
60
  if len(parts) > 1:
61
    port = int(parts[1])
62
  else:
63
    port = 80
64
  uri = url[2]
65
  http = True
66
  argi += 2
67
 
68
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
69
  framed = True
70
  argi += 1
71
 
72
cmd = sys.argv[argi]
73
args = sys.argv[argi+1:]
74
 
75
if http:
76
  transport = THttpClient.THttpClient(host, port, uri)
77
else:
78
  socket = TSocket.TSocket(host, port)
79
  if framed:
80
    transport = TTransport.TFramedTransport(socket)
81
  else:
82
    transport = TTransport.TBufferedTransport(socket)
83
protocol = TBinaryProtocol.TBinaryProtocol(transport)
84
client = HelperService.Client(protocol)
85
transport.open()
86
 
765 rajveer 87
if cmd == 'closeSession':
88
  if len(args) != 0:
89
    print 'closeSession requires 0 args'
90
    sys.exit(1)
91
  pp.pprint(client.closeSession())
92
 
1395 varun.gupt 93
elif cmd == 'saveUserEmailForSending':
94
  if len(args) != 6:
95
    print 'saveUserEmailForSending requires 6 args'
96
    sys.exit(1)
97
  pp.pprint(client.saveUserEmailForSending(args[0],args[1],args[2],args[3],args[4],args[5],))
98
 
1422 varun.gupt 99
elif cmd == 'getEmailsToBeSent':
100
  if len(args) != 1:
101
    print 'getEmailsToBeSent requires 1 args'
102
    sys.exit(1)
103
  pp.pprint(client.getEmailsToBeSent(args[0],))
104
 
105
elif cmd == 'markEmailAsSent':
106
  if len(args) != 1:
107
    print 'markEmailAsSent requires 1 args'
108
    sys.exit(1)
109
  pp.pprint(client.markEmailAsSent(eval(args[0]),))
110
 
765 rajveer 111
elif cmd == 'sendMail':
349 ashish 112
  if len(args) != 1:
113
    print 'sendMail requires 1 args'
114
    sys.exit(1)
115
  pp.pprint(client.sendMail(eval(args[0]),))
116
 
117
elif cmd == 'sendText':
118
  if len(args) != 1:
119
    print 'sendText requires 1 args'
120
    sys.exit(1)
121
  pp.pprint(client.sendText(eval(args[0]),))
122
 
123
elif cmd == 'addMessage':
124
  if len(args) != 1:
125
    print 'addMessage requires 1 args'
126
    sys.exit(1)
127
  pp.pprint(client.addMessage(eval(args[0]),))
128
 
129
elif cmd == 'updateMessage':
130
  if len(args) != 2:
131
    print 'updateMessage requires 2 args'
132
    sys.exit(1)
133
  pp.pprint(client.updateMessage(eval(args[0]),args[1],))
134
 
135
elif cmd == 'getMessage':
136
  if len(args) != 1:
137
    print 'getMessage requires 1 args'
138
    sys.exit(1)
139
  pp.pprint(client.getMessage(eval(args[0]),))
140
 
141
elif cmd == 'getSubstitutedMessage':
142
  if len(args) != 2:
143
    print 'getSubstitutedMessage requires 2 args'
144
    sys.exit(1)
145
  pp.pprint(client.getSubstitutedMessage(eval(args[0]),eval(args[1]),))
146
 
494 rajveer 147
elif cmd == 'addUser':
148
  if len(args) != 3:
149
    print 'addUser requires 3 args'
150
    sys.exit(1)
151
  pp.pprint(client.addUser(args[0],args[1],eval(args[2]),))
152
 
153
elif cmd == 'deleteUser':
154
  if len(args) != 1:
155
    print 'deleteUser requires 1 args'
156
    sys.exit(1)
157
  pp.pprint(client.deleteUser(args[0],))
158
 
159
elif cmd == 'authenticateUser':
160
  if len(args) != 2:
161
    print 'authenticateUser requires 2 args'
162
    sys.exit(1)
163
  pp.pprint(client.authenticateUser(args[0],args[1],))
164
 
165
elif cmd == 'updatePassword':
166
  if len(args) != 3:
167
    print 'updatePassword requires 3 args'
168
    sys.exit(1)
169
  pp.pprint(client.updatePassword(args[0],args[1],args[2],))
170
 
759 chandransh 171
elif cmd == 'authenticateLogisticsUser':
172
  if len(args) != 2:
173
    print 'authenticateLogisticsUser requires 2 args'
174
    sys.exit(1)
175
  pp.pprint(client.authenticateLogisticsUser(args[0],args[1],))
176
 
349 ashish 177
transport.close()