-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathTCLIService-remote
executable file
·264 lines (226 loc) · 7.87 KB
/
TCLIService-remote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!/usr/bin/env python
#
# Autogenerated by Thrift Compiler (0.17.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
# options string: py
#
import sys
import pprint
if sys.version_info[0] > 2:
from urllib.parse import urlparse
else:
from urlparse import urlparse
from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
from TCLIService import TCLIService
from TCLIService.ttypes import *
if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print('')
print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]')
print('')
print('Functions:')
print(' TOpenSessionResp OpenSession(TOpenSessionReq req)')
print(' TCloseSessionResp CloseSession(TCloseSessionReq req)')
print(' TGetInfoResp GetInfo(TGetInfoReq req)')
print(' TExecuteStatementResp ExecuteStatement(TExecuteStatementReq req)')
print(' TGetTypeInfoResp GetTypeInfo(TGetTypeInfoReq req)')
print(' TGetCatalogsResp GetCatalogs(TGetCatalogsReq req)')
print(' TGetSchemasResp GetSchemas(TGetSchemasReq req)')
print(' TGetTablesResp GetTables(TGetTablesReq req)')
print(' TGetTableTypesResp GetTableTypes(TGetTableTypesReq req)')
print(' TGetColumnsResp GetColumns(TGetColumnsReq req)')
print(' TGetFunctionsResp GetFunctions(TGetFunctionsReq req)')
print(' TGetPrimaryKeysResp GetPrimaryKeys(TGetPrimaryKeysReq req)')
print(' TGetCrossReferenceResp GetCrossReference(TGetCrossReferenceReq req)')
print(' TGetOperationStatusResp GetOperationStatus(TGetOperationStatusReq req)')
print(' TCancelOperationResp CancelOperation(TCancelOperationReq req)')
print(' TCloseOperationResp CloseOperation(TCloseOperationReq req)')
print(' TGetResultSetMetadataResp GetResultSetMetadata(TGetResultSetMetadataReq req)')
print(' TFetchResultsResp FetchResults(TFetchResultsReq req)')
print(' TGetDelegationTokenResp GetDelegationToken(TGetDelegationTokenReq req)')
print(' TCancelDelegationTokenResp CancelDelegationToken(TCancelDelegationTokenReq req)')
print(' TRenewDelegationTokenResp RenewDelegationToken(TRenewDelegationTokenReq req)')
print(' TDBSqlGetLoadInformationResp GetLoadInformation(TDBSqlGetLoadInformationReq req)')
print('')
sys.exit(0)
pp = pprint.PrettyPrinter(indent=2)
host = 'localhost'
port = 9090
uri = ''
framed = False
ssl = False
validate = True
ca_certs = None
keyfile = None
certfile = None
http = False
argi = 1
if sys.argv[argi] == '-h':
parts = sys.argv[argi + 1].split(':')
host = parts[0]
if len(parts) > 1:
port = int(parts[1])
argi += 2
if sys.argv[argi] == '-u':
url = urlparse(sys.argv[argi + 1])
parts = url[1].split(':')
host = parts[0]
if len(parts) > 1:
port = int(parts[1])
else:
port = 80
uri = url[2]
if url[4]:
uri += '?%s' % url[4]
http = True
argi += 2
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
framed = True
argi += 1
if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl':
ssl = True
argi += 1
if sys.argv[argi] == '-novalidate':
validate = False
argi += 1
if sys.argv[argi] == '-ca_certs':
ca_certs = sys.argv[argi+1]
argi += 2
if sys.argv[argi] == '-keyfile':
keyfile = sys.argv[argi+1]
argi += 2
if sys.argv[argi] == '-certfile':
certfile = sys.argv[argi+1]
argi += 2
cmd = sys.argv[argi]
args = sys.argv[argi + 1:]
if http:
transport = THttpClient.THttpClient(host, port, uri)
else:
if ssl:
socket = TSSLSocket.TSSLSocket(host, port, validate=validate, ca_certs=ca_certs, keyfile=keyfile, certfile=certfile)
else:
socket = TSocket.TSocket(host, port)
if framed:
transport = TTransport.TFramedTransport(socket)
else:
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol(transport)
client = TCLIService.Client(protocol)
transport.open()
if cmd == 'OpenSession':
if len(args) != 1:
print('OpenSession requires 1 args')
sys.exit(1)
pp.pprint(client.OpenSession(eval(args[0]),))
elif cmd == 'CloseSession':
if len(args) != 1:
print('CloseSession requires 1 args')
sys.exit(1)
pp.pprint(client.CloseSession(eval(args[0]),))
elif cmd == 'GetInfo':
if len(args) != 1:
print('GetInfo requires 1 args')
sys.exit(1)
pp.pprint(client.GetInfo(eval(args[0]),))
elif cmd == 'ExecuteStatement':
if len(args) != 1:
print('ExecuteStatement requires 1 args')
sys.exit(1)
pp.pprint(client.ExecuteStatement(eval(args[0]),))
elif cmd == 'GetTypeInfo':
if len(args) != 1:
print('GetTypeInfo requires 1 args')
sys.exit(1)
pp.pprint(client.GetTypeInfo(eval(args[0]),))
elif cmd == 'GetCatalogs':
if len(args) != 1:
print('GetCatalogs requires 1 args')
sys.exit(1)
pp.pprint(client.GetCatalogs(eval(args[0]),))
elif cmd == 'GetSchemas':
if len(args) != 1:
print('GetSchemas requires 1 args')
sys.exit(1)
pp.pprint(client.GetSchemas(eval(args[0]),))
elif cmd == 'GetTables':
if len(args) != 1:
print('GetTables requires 1 args')
sys.exit(1)
pp.pprint(client.GetTables(eval(args[0]),))
elif cmd == 'GetTableTypes':
if len(args) != 1:
print('GetTableTypes requires 1 args')
sys.exit(1)
pp.pprint(client.GetTableTypes(eval(args[0]),))
elif cmd == 'GetColumns':
if len(args) != 1:
print('GetColumns requires 1 args')
sys.exit(1)
pp.pprint(client.GetColumns(eval(args[0]),))
elif cmd == 'GetFunctions':
if len(args) != 1:
print('GetFunctions requires 1 args')
sys.exit(1)
pp.pprint(client.GetFunctions(eval(args[0]),))
elif cmd == 'GetPrimaryKeys':
if len(args) != 1:
print('GetPrimaryKeys requires 1 args')
sys.exit(1)
pp.pprint(client.GetPrimaryKeys(eval(args[0]),))
elif cmd == 'GetCrossReference':
if len(args) != 1:
print('GetCrossReference requires 1 args')
sys.exit(1)
pp.pprint(client.GetCrossReference(eval(args[0]),))
elif cmd == 'GetOperationStatus':
if len(args) != 1:
print('GetOperationStatus requires 1 args')
sys.exit(1)
pp.pprint(client.GetOperationStatus(eval(args[0]),))
elif cmd == 'CancelOperation':
if len(args) != 1:
print('CancelOperation requires 1 args')
sys.exit(1)
pp.pprint(client.CancelOperation(eval(args[0]),))
elif cmd == 'CloseOperation':
if len(args) != 1:
print('CloseOperation requires 1 args')
sys.exit(1)
pp.pprint(client.CloseOperation(eval(args[0]),))
elif cmd == 'GetResultSetMetadata':
if len(args) != 1:
print('GetResultSetMetadata requires 1 args')
sys.exit(1)
pp.pprint(client.GetResultSetMetadata(eval(args[0]),))
elif cmd == 'FetchResults':
if len(args) != 1:
print('FetchResults requires 1 args')
sys.exit(1)
pp.pprint(client.FetchResults(eval(args[0]),))
elif cmd == 'GetDelegationToken':
if len(args) != 1:
print('GetDelegationToken requires 1 args')
sys.exit(1)
pp.pprint(client.GetDelegationToken(eval(args[0]),))
elif cmd == 'CancelDelegationToken':
if len(args) != 1:
print('CancelDelegationToken requires 1 args')
sys.exit(1)
pp.pprint(client.CancelDelegationToken(eval(args[0]),))
elif cmd == 'RenewDelegationToken':
if len(args) != 1:
print('RenewDelegationToken requires 1 args')
sys.exit(1)
pp.pprint(client.RenewDelegationToken(eval(args[0]),))
elif cmd == 'GetLoadInformation':
if len(args) != 1:
print('GetLoadInformation requires 1 args')
sys.exit(1)
pp.pprint(client.GetLoadInformation(eval(args[0]),))
else:
print('Unrecognized method %s' % cmd)
sys.exit(1)
transport.close()