Subversion Repositories SmartDukaan

Rev

Rev 3103 | Rev 3431 | 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:'
669 chandransh 24
  print '  Provider getProvider(i64 providerId)'
675 chandransh 25
  print '   getAllProviders()'
647 chandransh 26
  print '  LogisticsInfo getLogisticsEstimation(i64 itemId, string destination_pin)'
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':
46
  parts = sys.argv[argi+1].split(':') 
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])
53
  parts = url[1].split(':') 
54
  host = parts[0]
55
  if len(parts) > 1:
56
    port = int(parts[1])
57
  else:
58
    port = 80
59
  uri = url[2]
60
  http = True
61
  argi += 2
62
 
63
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
64
  framed = True
65
  argi += 1
66
 
67
cmd = sys.argv[argi]
68
args = sys.argv[argi+1:]
69
 
70
if http:
71
  transport = THttpClient.THttpClient(host, port, uri)
72
else:
73
  socket = TSocket.TSocket(host, port)
74
  if framed:
75
    transport = TTransport.TFramedTransport(socket)
76
  else:
77
    transport = TTransport.TBufferedTransport(socket)
78
protocol = TBinaryProtocol.TBinaryProtocol(transport)
79
client = LogisticsService.Client(protocol)
80
transport.open()
81
 
3376 rajveer 82
if cmd == 'getProvider':
669 chandransh 83
  if len(args) != 1:
84
    print 'getProvider requires 1 args'
85
    sys.exit(1)
86
  pp.pprint(client.getProvider(eval(args[0]),))
87
 
675 chandransh 88
elif cmd == 'getAllProviders':
89
  if len(args) != 0:
90
    print 'getAllProviders requires 0 args'
91
    sys.exit(1)
92
  pp.pprint(client.getAllProviders())
93
 
669 chandransh 94
elif cmd == 'getLogisticsEstimation':
483 rajveer 95
  if len(args) != 2:
647 chandransh 96
    print 'getLogisticsEstimation requires 2 args'
483 rajveer 97
    sys.exit(1)
647 chandransh 98
  pp.pprint(client.getLogisticsEstimation(eval(args[0]),args[1],))
483 rajveer 99
 
647 chandransh 100
elif cmd == 'getLogisticsInfo':
3044 chandransh 101
  if len(args) != 3:
102
    print 'getLogisticsInfo requires 3 args'
412 ashish 103
    sys.exit(1)
3044 chandransh 104
  pp.pprint(client.getLogisticsInfo(args[0],eval(args[1]),eval(args[2]),))
412 ashish 105
 
106
elif cmd == 'getEmptyAWB':
107
  if len(args) != 1:
108
    print 'getEmptyAWB requires 1 args'
109
    sys.exit(1)
110
  pp.pprint(client.getEmptyAWB(eval(args[0]),))
111
 
112
elif cmd == 'getShipmentInfo':
647 chandransh 113
  if len(args) != 2:
114
    print 'getShipmentInfo requires 2 args'
412 ashish 115
    sys.exit(1)
647 chandransh 116
  pp.pprint(client.getShipmentInfo(args[0],eval(args[1]),))
412 ashish 117
 
732 chandransh 118
elif cmd == 'getDestinationCode':
119
  if len(args) != 2:
120
    print 'getDestinationCode requires 2 args'
121
    sys.exit(1)
122
  pp.pprint(client.getDestinationCode(eval(args[0]),args[1],))
123
 
1137 chandransh 124
elif cmd == 'getFreeAwbCount':
3103 chandransh 125
  if len(args) != 2:
126
    print 'getFreeAwbCount requires 2 args'
1137 chandransh 127
    sys.exit(1)
3103 chandransh 128
  pp.pprint(client.getFreeAwbCount(eval(args[0]),args[1],))
1137 chandransh 129
 
1730 ankur.sing 130
elif cmd == 'getHolidays':
131
  if len(args) != 2:
132
    print 'getHolidays requires 2 args'
133
    sys.exit(1)
134
  pp.pprint(client.getHolidays(eval(args[0]),eval(args[1]),))
135
 
3064 chandransh 136
elif cmd == 'isCodAllowed':
137
  if len(args) != 1:
138
    print 'isCodAllowed requires 1 args'
139
    sys.exit(1)
140
  pp.pprint(client.isCodAllowed(args[0],))
141
 
412 ashish 142
transport.close()