TCLIService-remote 8.3 KB

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