Subversion Repositories SmartDukaan

Rev

Rev 4630 | Rev 4934 | 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)'
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':
3431 rajveer 45
  parts = sys.argv[argi+1].split(':')
412 ashish 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])
3431 rajveer 52
  parts = url[1].split(':')
412 ashish 53
  host = parts[0]
54
  if len(parts) > 1:
55
    port = int(parts[1])
56
  else:
57
    port = 80
58
  uri = url[2]
3431 rajveer 59
  if url[4]:
60
    uri += '?%s' % url[4]
412 ashish 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
 
3376 rajveer 83
if cmd == 'getProvider':
669 chandransh 84
  if len(args) != 1:
85
    print 'getProvider requires 1 args'
86
    sys.exit(1)
87
  pp.pprint(client.getProvider(eval(args[0]),))
88
 
675 chandransh 89
elif cmd == 'getAllProviders':
90
  if len(args) != 0:
91
    print 'getAllProviders requires 0 args'
92
    sys.exit(1)
93
  pp.pprint(client.getAllProviders())
94
 
669 chandransh 95
elif cmd == 'getLogisticsEstimation':
4630 mandeep.dh 96
  if len(args) != 3:
97
    print 'getLogisticsEstimation requires 3 args'
483 rajveer 98
    sys.exit(1)
4630 mandeep.dh 99
  pp.pprint(client.getLogisticsEstimation(eval(args[0]),args[1],eval(args[2]),))
483 rajveer 100
 
647 chandransh 101
elif cmd == 'getLogisticsInfo':
3044 chandransh 102
  if len(args) != 3:
103
    print 'getLogisticsInfo requires 3 args'
412 ashish 104
    sys.exit(1)
3044 chandransh 105
  pp.pprint(client.getLogisticsInfo(args[0],eval(args[1]),eval(args[2]),))
412 ashish 106
 
107
elif cmd == 'getEmptyAWB':
108
  if len(args) != 1:
109
    print 'getEmptyAWB requires 1 args'
110
    sys.exit(1)
111
  pp.pprint(client.getEmptyAWB(eval(args[0]),))
112
 
113
elif cmd == 'getShipmentInfo':
647 chandransh 114
  if len(args) != 2:
115
    print 'getShipmentInfo requires 2 args'
412 ashish 116
    sys.exit(1)
647 chandransh 117
  pp.pprint(client.getShipmentInfo(args[0],eval(args[1]),))
412 ashish 118
 
732 chandransh 119
elif cmd == 'getDestinationCode':
120
  if len(args) != 2:
121
    print 'getDestinationCode requires 2 args'
122
    sys.exit(1)
123
  pp.pprint(client.getDestinationCode(eval(args[0]),args[1],))
124
 
1137 chandransh 125
elif cmd == 'getFreeAwbCount':
3103 chandransh 126
  if len(args) != 2:
127
    print 'getFreeAwbCount requires 2 args'
1137 chandransh 128
    sys.exit(1)
3103 chandransh 129
  pp.pprint(client.getFreeAwbCount(eval(args[0]),args[1],))
1137 chandransh 130
 
1730 ankur.sing 131
elif cmd == 'getHolidays':
132
  if len(args) != 2:
133
    print 'getHolidays requires 2 args'
134
    sys.exit(1)
135
  pp.pprint(client.getHolidays(eval(args[0]),eval(args[1]),))
136
 
3431 rajveer 137
else:
138
  print 'Unrecognized method %s' % cmd
139
  sys.exit(1)
140
 
412 ashish 141
transport.close()