Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
412 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 LogisticsService
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()'
669 chandransh 25
  print '  Provider getProvider(i64 providerId)'
675 chandransh 26
  print '   getAllProviders()'
647 chandransh 27
  print '  LogisticsInfo getLogisticsEstimation(i64 itemId, string destination_pin)'
716 rajveer 28
  print '  LogisticsInfo getLogisticsInfo(string destination_pincode, i64 item_id)'
647 chandransh 29
  print '  string getEmptyAWB(i64 providerId)'
30
  print '   getShipmentInfo(string awb, i64 providerId)'
732 chandransh 31
  print '  string getDestinationCode(i64 providerId, string pinCode)'
1137 chandransh 32
  print '  i64 getFreeAwbCount(i64 providerId)'
412 ashish 33
  print ''
34
  sys.exit(0)
35
 
36
pp = pprint.PrettyPrinter(indent = 2)
37
host = 'localhost'
38
port = 9090
39
uri = ''
40
framed = False
41
http = False
42
argi = 1
43
 
44
if sys.argv[argi] == '-h':
45
  parts = sys.argv[argi+1].split(':') 
46
  host = parts[0]
47
  port = int(parts[1])
48
  argi += 2
49
 
50
if sys.argv[argi] == '-u':
51
  url = urlparse(sys.argv[argi+1])
52
  parts = url[1].split(':') 
53
  host = parts[0]
54
  if len(parts) > 1:
55
    port = int(parts[1])
56
  else:
57
    port = 80
58
  uri = url[2]
59
  http = True
60
  argi += 2
61
 
62
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
63
  framed = True
64
  argi += 1
65
 
66
cmd = sys.argv[argi]
67
args = sys.argv[argi+1:]
68
 
69
if http:
70
  transport = THttpClient.THttpClient(host, port, uri)
71
else:
72
  socket = TSocket.TSocket(host, port)
73
  if framed:
74
    transport = TTransport.TFramedTransport(socket)
75
  else:
76
    transport = TTransport.TBufferedTransport(socket)
77
protocol = TBinaryProtocol.TBinaryProtocol(transport)
78
client = LogisticsService.Client(protocol)
79
transport.open()
80
 
765 rajveer 81
if cmd == 'closeSession':
82
  if len(args) != 0:
83
    print 'closeSession requires 0 args'
84
    sys.exit(1)
85
  pp.pprint(client.closeSession())
86
 
87
elif cmd == 'getProvider':
669 chandransh 88
  if len(args) != 1:
89
    print 'getProvider requires 1 args'
90
    sys.exit(1)
91
  pp.pprint(client.getProvider(eval(args[0]),))
92
 
675 chandransh 93
elif cmd == 'getAllProviders':
94
  if len(args) != 0:
95
    print 'getAllProviders requires 0 args'
96
    sys.exit(1)
97
  pp.pprint(client.getAllProviders())
98
 
669 chandransh 99
elif cmd == 'getLogisticsEstimation':
483 rajveer 100
  if len(args) != 2:
647 chandransh 101
    print 'getLogisticsEstimation requires 2 args'
483 rajveer 102
    sys.exit(1)
647 chandransh 103
  pp.pprint(client.getLogisticsEstimation(eval(args[0]),args[1],))
483 rajveer 104
 
647 chandransh 105
elif cmd == 'getLogisticsInfo':
412 ashish 106
  if len(args) != 2:
647 chandransh 107
    print 'getLogisticsInfo requires 2 args'
412 ashish 108
    sys.exit(1)
716 rajveer 109
  pp.pprint(client.getLogisticsInfo(args[0],eval(args[1]),))
412 ashish 110
 
111
elif cmd == 'getEmptyAWB':
112
  if len(args) != 1:
113
    print 'getEmptyAWB requires 1 args'
114
    sys.exit(1)
115
  pp.pprint(client.getEmptyAWB(eval(args[0]),))
116
 
117
elif cmd == 'getShipmentInfo':
647 chandransh 118
  if len(args) != 2:
119
    print 'getShipmentInfo requires 2 args'
412 ashish 120
    sys.exit(1)
647 chandransh 121
  pp.pprint(client.getShipmentInfo(args[0],eval(args[1]),))
412 ashish 122
 
732 chandransh 123
elif cmd == 'getDestinationCode':
124
  if len(args) != 2:
125
    print 'getDestinationCode requires 2 args'
126
    sys.exit(1)
127
  pp.pprint(client.getDestinationCode(eval(args[0]),args[1],))
128
 
1137 chandransh 129
elif cmd == 'getFreeAwbCount':
130
  if len(args) != 1:
131
    print 'getFreeAwbCount requires 1 args'
132
    sys.exit(1)
133
  pp.pprint(client.getFreeAwbCount(eval(args[0]),))
134
 
412 ashish 135
transport.close()