Subversion Repositories SmartDukaan

Rev

Rev 5247 | Rev 5553 | 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)'
5247 rajveer 28
  print '  string getEmptyAWB(i64 providerId, DeliveryType type)'
647 chandransh 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)'
4934 amit.gupta 33
  print '   getEntityLogisticsEstimation(i64 catalogItemId, string destination_pin, DeliveryType type)'
5527 anupam.sin 34
  print '  i64 getProviderForPickupType(i64 pickUp)'
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':
3431 rajveer 47
  parts = sys.argv[argi+1].split(':')
412 ashish 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])
3431 rajveer 54
  parts = url[1].split(':')
412 ashish 55
  host = parts[0]
56
  if len(parts) > 1:
57
    port = int(parts[1])
58
  else:
59
    port = 80
60
  uri = url[2]
3431 rajveer 61
  if url[4]:
62
    uri += '?%s' % url[4]
412 ashish 63
  http = True
64
  argi += 2
65
 
66
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
67
  framed = True
68
  argi += 1
69
 
70
cmd = sys.argv[argi]
71
args = sys.argv[argi+1:]
72
 
73
if http:
74
  transport = THttpClient.THttpClient(host, port, uri)
75
else:
76
  socket = TSocket.TSocket(host, port)
77
  if framed:
78
    transport = TTransport.TFramedTransport(socket)
79
  else:
80
    transport = TTransport.TBufferedTransport(socket)
81
protocol = TBinaryProtocol.TBinaryProtocol(transport)
82
client = LogisticsService.Client(protocol)
83
transport.open()
84
 
3376 rajveer 85
if cmd == 'getProvider':
669 chandransh 86
  if len(args) != 1:
87
    print 'getProvider requires 1 args'
88
    sys.exit(1)
89
  pp.pprint(client.getProvider(eval(args[0]),))
90
 
675 chandransh 91
elif cmd == 'getAllProviders':
92
  if len(args) != 0:
93
    print 'getAllProviders requires 0 args'
94
    sys.exit(1)
95
  pp.pprint(client.getAllProviders())
96
 
669 chandransh 97
elif cmd == 'getLogisticsEstimation':
4630 mandeep.dh 98
  if len(args) != 3:
99
    print 'getLogisticsEstimation requires 3 args'
483 rajveer 100
    sys.exit(1)
4630 mandeep.dh 101
  pp.pprint(client.getLogisticsEstimation(eval(args[0]),args[1],eval(args[2]),))
483 rajveer 102
 
647 chandransh 103
elif cmd == 'getLogisticsInfo':
3044 chandransh 104
  if len(args) != 3:
105
    print 'getLogisticsInfo requires 3 args'
412 ashish 106
    sys.exit(1)
3044 chandransh 107
  pp.pprint(client.getLogisticsInfo(args[0],eval(args[1]),eval(args[2]),))
412 ashish 108
 
109
elif cmd == 'getEmptyAWB':
5247 rajveer 110
  if len(args) != 2:
111
    print 'getEmptyAWB requires 2 args'
412 ashish 112
    sys.exit(1)
5247 rajveer 113
  pp.pprint(client.getEmptyAWB(eval(args[0]),eval(args[1]),))
412 ashish 114
 
115
elif cmd == 'getShipmentInfo':
647 chandransh 116
  if len(args) != 2:
117
    print 'getShipmentInfo requires 2 args'
412 ashish 118
    sys.exit(1)
647 chandransh 119
  pp.pprint(client.getShipmentInfo(args[0],eval(args[1]),))
412 ashish 120
 
732 chandransh 121
elif cmd == 'getDestinationCode':
122
  if len(args) != 2:
123
    print 'getDestinationCode requires 2 args'
124
    sys.exit(1)
125
  pp.pprint(client.getDestinationCode(eval(args[0]),args[1],))
126
 
1137 chandransh 127
elif cmd == 'getFreeAwbCount':
3103 chandransh 128
  if len(args) != 2:
129
    print 'getFreeAwbCount requires 2 args'
1137 chandransh 130
    sys.exit(1)
3103 chandransh 131
  pp.pprint(client.getFreeAwbCount(eval(args[0]),args[1],))
1137 chandransh 132
 
1730 ankur.sing 133
elif cmd == 'getHolidays':
134
  if len(args) != 2:
135
    print 'getHolidays requires 2 args'
136
    sys.exit(1)
137
  pp.pprint(client.getHolidays(eval(args[0]),eval(args[1]),))
138
 
4934 amit.gupta 139
elif cmd == 'getEntityLogisticsEstimation':
140
  if len(args) != 3:
141
    print 'getEntityLogisticsEstimation requires 3 args'
142
    sys.exit(1)
143
  pp.pprint(client.getEntityLogisticsEstimation(eval(args[0]),args[1],eval(args[2]),))
144
 
5527 anupam.sin 145
elif cmd == 'getProviderForPickupType':
146
  if len(args) != 1:
147
    print 'getProviderForPickupType requires 1 args'
148
    sys.exit(1)
149
  pp.pprint(client.getProviderForPickupType(eval(args[0]),))
150
 
3431 rajveer 151
else:
152
  print 'Unrecognized method %s' % cmd
153
  sys.exit(1)
154
 
412 ashish 155
transport.close()