Subversion Repositories SmartDukaan

Rev

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