Subversion Repositories SmartDukaan

Rev

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