Subversion Repositories SmartDukaan

Rev

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