Subversion Repositories SmartDukaan

Rev

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