aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dominoCLI/DominoClientCLI-remote
diff options
context:
space:
mode:
authorUlas Kozat <ulas.kozat@gmail.com>2016-06-01 16:21:13 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-06-01 16:21:13 +0000
commitba0d2a3caab1de4d20ff4f43318d9b24732e33cf (patch)
tree81d2ad5b11d6b410ef9bdae0cbe183d421d9c99e /lib/dominoCLI/DominoClientCLI-remote
parent70dd36828ef1efca9204c15deacea25bc69a8709 (diff)
parentb1486d4aeb0e37e0cb8fd31110af1e52d9a155fe (diff)
Merge "refactored codes, added standalone CLI client, option of interactive vs. standalone CLI"
Diffstat (limited to 'lib/dominoCLI/DominoClientCLI-remote')
-rwxr-xr-xlib/dominoCLI/DominoClientCLI-remote94
1 files changed, 94 insertions, 0 deletions
diff --git a/lib/dominoCLI/DominoClientCLI-remote b/lib/dominoCLI/DominoClientCLI-remote
new file mode 100755
index 0000000..da93c65
--- /dev/null
+++ b/lib/dominoCLI/DominoClientCLI-remote
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+#
+# Autogenerated by Thrift Compiler (0.9.3)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+# options string: py
+#
+
+import sys
+import pprint
+from urlparse import urlparse
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import TSSLSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+
+from dominoCLI import DominoClientCLI
+from dominoCLI.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]] function [arg1 [arg2...]]')
+ print('')
+ print('Functions:')
+ print(' CLIResponse d_CLI(CLIMessage msg)')
+ print('')
+ sys.exit(0)
+
+pp = pprint.PrettyPrinter(indent = 2)
+host = 'localhost'
+port = 9090
+uri = ''
+framed = False
+ssl = False
+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
+
+cmd = sys.argv[argi]
+args = sys.argv[argi+1:]
+
+if http:
+ transport = THttpClient.THttpClient(host, port, uri)
+else:
+ socket = TSSLSocket.TSSLSocket(host, port, validate=False) if ssl else TSocket.TSocket(host, port)
+ if framed:
+ transport = TTransport.TFramedTransport(socket)
+ else:
+ transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = DominoClientCLI.Client(protocol)
+transport.open()
+
+if cmd == 'd_CLI':
+ if len(args) != 1:
+ print('d_CLI requires 1 args')
+ sys.exit(1)
+ pp.pprint(client.d_CLI(eval(args[0]),))
+
+else:
+ print('Unrecognized method %s' % cmd)
+ sys.exit(1)
+
+transport.close()