Subversion Repositories SmartDukaan

Rev

Rev 3044 | Rev 3103 | 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)'
3044 chandransh 28
  print '  LogisticsInfo getLogisticsInfo(string destination_pincode, i64 item_id, DeliveryType type)'
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)'
1730 ankur.sing 33
  print '   getHolidays(i64 fromDate, i64 toDate)'
3064 chandransh 34
  print '  bool isCodAllowed(string destination_pincode)'
412 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 = LogisticsService.Client(protocol)
81
transport.open()
82
 
765 rajveer 83
if cmd == 'closeSession':
84
  if len(args) != 0:
85
    print 'closeSession requires 0 args'
86
    sys.exit(1)
87
  pp.pprint(client.closeSession())
88
 
89
elif cmd == 'getProvider':
669 chandransh 90
  if len(args) != 1:
91
    print 'getProvider requires 1 args'
92
    sys.exit(1)
93
  pp.pprint(client.getProvider(eval(args[0]),))
94
 
675 chandransh 95
elif cmd == 'getAllProviders':
96
  if len(args) != 0:
97
    print 'getAllProviders requires 0 args'
98
    sys.exit(1)
99
  pp.pprint(client.getAllProviders())
100
 
669 chandransh 101
elif cmd == 'getLogisticsEstimation':
483 rajveer 102
  if len(args) != 2:
647 chandransh 103
    print 'getLogisticsEstimation requires 2 args'
483 rajveer 104
    sys.exit(1)
647 chandransh 105
  pp.pprint(client.getLogisticsEstimation(eval(args[0]),args[1],))
483 rajveer 106
 
647 chandransh 107
elif cmd == 'getLogisticsInfo':
3044 chandransh 108
  if len(args) != 3:
109
    print 'getLogisticsInfo requires 3 args'
412 ashish 110
    sys.exit(1)
3044 chandransh 111
  pp.pprint(client.getLogisticsInfo(args[0],eval(args[1]),eval(args[2]),))
412 ashish 112
 
113
elif cmd == 'getEmptyAWB':
114
  if len(args) != 1:
115
    print 'getEmptyAWB requires 1 args'
116
    sys.exit(1)
117
  pp.pprint(client.getEmptyAWB(eval(args[0]),))
118
 
119
elif cmd == 'getShipmentInfo':
647 chandransh 120
  if len(args) != 2:
121
    print 'getShipmentInfo requires 2 args'
412 ashish 122
    sys.exit(1)
647 chandransh 123
  pp.pprint(client.getShipmentInfo(args[0],eval(args[1]),))
412 ashish 124
 
732 chandransh 125
elif cmd == 'getDestinationCode':
126
  if len(args) != 2:
127
    print 'getDestinationCode requires 2 args'
128
    sys.exit(1)
129
  pp.pprint(client.getDestinationCode(eval(args[0]),args[1],))
130
 
1137 chandransh 131
elif cmd == 'getFreeAwbCount':
132
  if len(args) != 1:
133
    print 'getFreeAwbCount requires 1 args'
134
    sys.exit(1)
135
  pp.pprint(client.getFreeAwbCount(eval(args[0]),))
136
 
1730 ankur.sing 137
elif cmd == 'getHolidays':
138
  if len(args) != 2:
139
    print 'getHolidays requires 2 args'
140
    sys.exit(1)
141
  pp.pprint(client.getHolidays(eval(args[0]),eval(args[1]),))
142
 
3064 chandransh 143
elif cmd == 'isCodAllowed':
144
  if len(args) != 1:
145
    print 'isCodAllowed requires 1 args'
146
    sys.exit(1)
147
  pp.pprint(client.isCodAllowed(args[0],))
148
 
412 ashish 149
transport.close()