Subversion Repositories SmartDukaan

Rev

Rev 4391 | Rev 4865 | 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
#
3431 rajveer 3
# Autogenerated by Thrift Compiler (0.7.0)
412 ashish 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:'
669 chandransh 24
  print '  Provider getProvider(i64 providerId)'
675 chandransh 25
  print '   getAllProviders()'
4630 mandeep.dh 26
  print '  LogisticsInfo getLogisticsEstimation(i64 itemId, string destination_pin, DeliveryType type)'
3044 chandransh 27
  print '  LogisticsInfo getLogisticsInfo(string destination_pincode, i64 item_id, DeliveryType type)'
647 chandransh 28
  print '  string getEmptyAWB(i64 providerId)'
29
  print '   getShipmentInfo(string awb, i64 providerId)'
732 chandransh 30
  print '  string getDestinationCode(i64 providerId, string pinCode)'
3103 chandransh 31
  print '  i64 getFreeAwbCount(i64 providerId, string type)'
1730 ankur.sing 32
  print '   getHolidays(i64 fromDate, i64 toDate)'
3064 chandransh 33
  print '  bool isCodAllowed(string destination_pincode)'
412 ashish 34
  print ''
35
  sys.exit(0)
36
 
37
pp = pprint.PrettyPrinter(indent = 2)
38
host = 'localhost'
39
port = 9090
40
uri = ''
41
framed = False
42
http = False
43
argi = 1
44
 
45
if sys.argv[argi] == '-h':
3431 rajveer 46
  parts = sys.argv[argi+1].split(':')
412 ashish 47
  host = parts[0]
48
  port = int(parts[1])
49
  argi += 2
50
 
51
if sys.argv[argi] == '-u':
52
  url = urlparse(sys.argv[argi+1])
3431 rajveer 53
  parts = url[1].split(':')
412 ashish 54
  host = parts[0]
55
  if len(parts) > 1:
56
    port = int(parts[1])
57
  else:
58
    port = 80
59
  uri = url[2]
3431 rajveer 60
  if url[4]:
61
    uri += '?%s' % url[4]
412 ashish 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 = LogisticsService.Client(protocol)
82
transport.open()
83
 
3376 rajveer 84
if cmd == 'getProvider':
669 chandransh 85
  if len(args) != 1:
86
    print 'getProvider requires 1 args'
87
    sys.exit(1)
88
  pp.pprint(client.getProvider(eval(args[0]),))
89
 
675 chandransh 90
elif cmd == 'getAllProviders':
91
  if len(args) != 0:
92
    print 'getAllProviders requires 0 args'
93
    sys.exit(1)
94
  pp.pprint(client.getAllProviders())
95
 
669 chandransh 96
elif cmd == 'getLogisticsEstimation':
4630 mandeep.dh 97
  if len(args) != 3:
98
    print 'getLogisticsEstimation requires 3 args'
483 rajveer 99
    sys.exit(1)
4630 mandeep.dh 100
  pp.pprint(client.getLogisticsEstimation(eval(args[0]),args[1],eval(args[2]),))
483 rajveer 101
 
647 chandransh 102
elif cmd == 'getLogisticsInfo':
3044 chandransh 103
  if len(args) != 3:
104
    print 'getLogisticsInfo requires 3 args'
412 ashish 105
    sys.exit(1)
3044 chandransh 106
  pp.pprint(client.getLogisticsInfo(args[0],eval(args[1]),eval(args[2]),))
412 ashish 107
 
108
elif cmd == 'getEmptyAWB':
109
  if len(args) != 1:
110
    print 'getEmptyAWB requires 1 args'
111
    sys.exit(1)
112
  pp.pprint(client.getEmptyAWB(eval(args[0]),))
113
 
114
elif cmd == 'getShipmentInfo':
647 chandransh 115
  if len(args) != 2:
116
    print 'getShipmentInfo requires 2 args'
412 ashish 117
    sys.exit(1)
647 chandransh 118
  pp.pprint(client.getShipmentInfo(args[0],eval(args[1]),))
412 ashish 119
 
732 chandransh 120
elif cmd == 'getDestinationCode':
121
  if len(args) != 2:
122
    print 'getDestinationCode requires 2 args'
123
    sys.exit(1)
124
  pp.pprint(client.getDestinationCode(eval(args[0]),args[1],))
125
 
1137 chandransh 126
elif cmd == 'getFreeAwbCount':
3103 chandransh 127
  if len(args) != 2:
128
    print 'getFreeAwbCount requires 2 args'
1137 chandransh 129
    sys.exit(1)
3103 chandransh 130
  pp.pprint(client.getFreeAwbCount(eval(args[0]),args[1],))
1137 chandransh 131
 
1730 ankur.sing 132
elif cmd == 'getHolidays':
133
  if len(args) != 2:
134
    print 'getHolidays requires 2 args'
135
    sys.exit(1)
136
  pp.pprint(client.getHolidays(eval(args[0]),eval(args[1]),))
137
 
3064 chandransh 138
elif cmd == 'isCodAllowed':
139
  if len(args) != 1:
140
    print 'isCodAllowed requires 1 args'
141
    sys.exit(1)
142
  pp.pprint(client.isCodAllowed(args[0],))
143
 
3431 rajveer 144
else:
145
  print 'Unrecognized method %s' % cmd
146
  sys.exit(1)
147
 
412 ashish 148
transport.close()