summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorUlas Kozat <ulas.kozat@gmail.com>2016-05-27 23:26:54 -0700
committerUlas Kozat <ulas.kozat@gmail.com>2016-05-27 23:26:54 -0700
commitb1486d4aeb0e37e0cb8fd31110af1e52d9a155fe (patch)
tree72023b56eff903a4681e4ca74bd02f28f83e7dfb /lib
parent4435444272ac1849ef3a2dc3dca7931fabfd98cb (diff)
refactored codes, added standalone CLI client, option of interactive vs. standalone CLI
Change-Id: I262aaf4f5908c0d9b7eae87699c49ba385437589 Signed-off-by: Ulas Kozat <ulas.kozat@gmail.com>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/dominoCLI/DominoClientCLI-remote94
-rw-r--r--lib/dominoCLI/DominoClientCLI.py241
-rw-r--r--lib/dominoCLI/DominoClientCLI.pycbin0 -> 9096 bytes
-rw-r--r--lib/dominoCLI/__init__.py1
-rw-r--r--lib/dominoCLI/__init__.pycbin0 -> 186 bytes
-rw-r--r--lib/dominoCLI/constants.py11
-rw-r--r--lib/dominoCLI/constants.pycbin0 -> 299 bytes
-rw-r--r--lib/dominoCLI/ttypes.py159
-rw-r--r--lib/dominoCLI/ttypes.pycbin0 -> 5839 bytes
9 files changed, 506 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()
diff --git a/lib/dominoCLI/DominoClientCLI.py b/lib/dominoCLI/DominoClientCLI.py
new file mode 100644
index 0000000..c0d28c7
--- /dev/null
+++ b/lib/dominoCLI/DominoClientCLI.py
@@ -0,0 +1,241 @@
+#
+# Autogenerated by Thrift Compiler (0.9.3)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+# options string: py
+#
+
+from thrift.Thrift import TType, TMessageType, TException, TApplicationException
+import logging
+from ttypes import *
+from thrift.Thrift import TProcessor
+from thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+ from thrift.protocol import fastbinary
+except:
+ fastbinary = None
+
+
+class Iface:
+ def d_CLI(self, msg):
+ """
+ Parameters:
+ - msg
+ """
+ pass
+
+
+class Client(Iface):
+ def __init__(self, iprot, oprot=None):
+ self._iprot = self._oprot = iprot
+ if oprot is not None:
+ self._oprot = oprot
+ self._seqid = 0
+
+ def d_CLI(self, msg):
+ """
+ Parameters:
+ - msg
+ """
+ self.send_d_CLI(msg)
+ return self.recv_d_CLI()
+
+ def send_d_CLI(self, msg):
+ self._oprot.writeMessageBegin('d_CLI', TMessageType.CALL, self._seqid)
+ args = d_CLI_args()
+ args.msg = msg
+ args.write(self._oprot)
+ self._oprot.writeMessageEnd()
+ self._oprot.trans.flush()
+
+ def recv_d_CLI(self):
+ iprot = self._iprot
+ (fname, mtype, rseqid) = iprot.readMessageBegin()
+ if mtype == TMessageType.EXCEPTION:
+ x = TApplicationException()
+ x.read(iprot)
+ iprot.readMessageEnd()
+ raise x
+ result = d_CLI_result()
+ result.read(iprot)
+ iprot.readMessageEnd()
+ if result.success is not None:
+ return result.success
+ raise TApplicationException(TApplicationException.MISSING_RESULT, "d_CLI failed: unknown result")
+
+
+class Processor(Iface, TProcessor):
+ def __init__(self, handler):
+ self._handler = handler
+ self._processMap = {}
+ self._processMap["d_CLI"] = Processor.process_d_CLI
+
+ def process(self, iprot, oprot):
+ (name, type, seqid) = iprot.readMessageBegin()
+ if name not in self._processMap:
+ iprot.skip(TType.STRUCT)
+ iprot.readMessageEnd()
+ x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name))
+ oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
+ x.write(oprot)
+ oprot.writeMessageEnd()
+ oprot.trans.flush()
+ return
+ else:
+ self._processMap[name](self, seqid, iprot, oprot)
+ return True
+
+ def process_d_CLI(self, seqid, iprot, oprot):
+ args = d_CLI_args()
+ args.read(iprot)
+ iprot.readMessageEnd()
+ result = d_CLI_result()
+ try:
+ result.success = self._handler.d_CLI(args.msg)
+ msg_type = TMessageType.REPLY
+ except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
+ raise
+ except Exception as ex:
+ msg_type = TMessageType.EXCEPTION
+ logging.exception(ex)
+ result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
+ oprot.writeMessageBegin("d_CLI", msg_type, seqid)
+ result.write(oprot)
+ oprot.writeMessageEnd()
+ oprot.trans.flush()
+
+
+# HELPER FUNCTIONS AND STRUCTURES
+
+class d_CLI_args:
+ """
+ Attributes:
+ - msg
+ """
+
+ thrift_spec = (
+ None, # 0
+ (1, TType.STRUCT, 'msg', (CLIMessage, CLIMessage.thrift_spec), None, ), # 1
+ )
+
+ def __init__(self, msg=None,):
+ self.msg = msg
+
+ def read(self, iprot):
+ if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+ fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+ return
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.STRUCT:
+ self.msg = CLIMessage()
+ self.msg.read(iprot)
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+ oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStructBegin('d_CLI_args')
+ if self.msg is not None:
+ oprot.writeFieldBegin('msg', TType.STRUCT, 1)
+ self.msg.write(oprot)
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
+
+ def validate(self):
+ return
+
+
+ def __hash__(self):
+ value = 17
+ value = (value * 31) ^ hash(self.msg)
+ return value
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, value)
+ for key, value in self.__dict__.iteritems()]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+ def __ne__(self, other):
+ return not (self == other)
+
+class d_CLI_result:
+ """
+ Attributes:
+ - success
+ """
+
+ thrift_spec = (
+ (0, TType.STRUCT, 'success', (CLIResponse, CLIResponse.thrift_spec), None, ), # 0
+ )
+
+ def __init__(self, success=None,):
+ self.success = success
+
+ def read(self, iprot):
+ if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+ fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+ return
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 0:
+ if ftype == TType.STRUCT:
+ self.success = CLIResponse()
+ self.success.read(iprot)
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+ oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStructBegin('d_CLI_result')
+ if self.success is not None:
+ oprot.writeFieldBegin('success', TType.STRUCT, 0)
+ self.success.write(oprot)
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
+
+ def validate(self):
+ return
+
+
+ def __hash__(self):
+ value = 17
+ value = (value * 31) ^ hash(self.success)
+ return value
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, value)
+ for key, value in self.__dict__.iteritems()]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+ def __ne__(self, other):
+ return not (self == other)
diff --git a/lib/dominoCLI/DominoClientCLI.pyc b/lib/dominoCLI/DominoClientCLI.pyc
new file mode 100644
index 0000000..0c01101
--- /dev/null
+++ b/lib/dominoCLI/DominoClientCLI.pyc
Binary files differ
diff --git a/lib/dominoCLI/__init__.py b/lib/dominoCLI/__init__.py
new file mode 100644
index 0000000..e52a87f
--- /dev/null
+++ b/lib/dominoCLI/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants', 'DominoClientCLI']
diff --git a/lib/dominoCLI/__init__.pyc b/lib/dominoCLI/__init__.pyc
new file mode 100644
index 0000000..dfa3544
--- /dev/null
+++ b/lib/dominoCLI/__init__.pyc
Binary files differ
diff --git a/lib/dominoCLI/constants.py b/lib/dominoCLI/constants.py
new file mode 100644
index 0000000..4a6492b
--- /dev/null
+++ b/lib/dominoCLI/constants.py
@@ -0,0 +1,11 @@
+#
+# Autogenerated by Thrift Compiler (0.9.3)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+# options string: py
+#
+
+from thrift.Thrift import TType, TMessageType, TException, TApplicationException
+from ttypes import *
+
diff --git a/lib/dominoCLI/constants.pyc b/lib/dominoCLI/constants.pyc
new file mode 100644
index 0000000..466e728
--- /dev/null
+++ b/lib/dominoCLI/constants.pyc
Binary files differ
diff --git a/lib/dominoCLI/ttypes.py b/lib/dominoCLI/ttypes.py
new file mode 100644
index 0000000..9794dba
--- /dev/null
+++ b/lib/dominoCLI/ttypes.py
@@ -0,0 +1,159 @@
+#
+# Autogenerated by Thrift Compiler (0.9.3)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+# options string: py
+#
+
+from thrift.Thrift import TType, TMessageType, TException, TApplicationException
+
+from thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+ from thrift.protocol import fastbinary
+except:
+ fastbinary = None
+
+
+
+class CLIMessage:
+ """
+ Domino sends periodic heartbeats from
+ Domino Clients and Domino Server echos
+
+ Attributes:
+ - CLI_input
+ """
+
+ thrift_spec = (
+ None, # 0
+ (1, TType.LIST, 'CLI_input', (TType.STRING,None), None, ), # 1
+ )
+
+ def __init__(self, CLI_input=None,):
+ self.CLI_input = CLI_input
+
+ def read(self, iprot):
+ if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+ fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+ return
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.LIST:
+ self.CLI_input = []
+ (_etype3, _size0) = iprot.readListBegin()
+ for _i4 in xrange(_size0):
+ _elem5 = iprot.readString()
+ self.CLI_input.append(_elem5)
+ iprot.readListEnd()
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+ oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStructBegin('CLIMessage')
+ if self.CLI_input is not None:
+ oprot.writeFieldBegin('CLI_input', TType.LIST, 1)
+ oprot.writeListBegin(TType.STRING, len(self.CLI_input))
+ for iter6 in self.CLI_input:
+ oprot.writeString(iter6)
+ oprot.writeListEnd()
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
+
+ def validate(self):
+ return
+
+
+ def __hash__(self):
+ value = 17
+ value = (value * 31) ^ hash(self.CLI_input)
+ return value
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, value)
+ for key, value in self.__dict__.iteritems()]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+ def __ne__(self, other):
+ return not (self == other)
+
+class CLIResponse:
+ """
+ Attributes:
+ - CLI_response
+ """
+
+ thrift_spec = (
+ None, # 0
+ (1, TType.STRING, 'CLI_response', None, None, ), # 1
+ )
+
+ def __init__(self, CLI_response=None,):
+ self.CLI_response = CLI_response
+
+ def read(self, iprot):
+ if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+ fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+ return
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.STRING:
+ self.CLI_response = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+ oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStructBegin('CLIResponse')
+ if self.CLI_response is not None:
+ oprot.writeFieldBegin('CLI_response', TType.STRING, 1)
+ oprot.writeString(self.CLI_response)
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
+
+ def validate(self):
+ return
+
+
+ def __hash__(self):
+ value = 17
+ value = (value * 31) ^ hash(self.CLI_response)
+ return value
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, value)
+ for key, value in self.__dict__.iteritems()]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+ def __ne__(self, other):
+ return not (self == other)
diff --git a/lib/dominoCLI/ttypes.pyc b/lib/dominoCLI/ttypes.pyc
new file mode 100644
index 0000000..03a5979
--- /dev/null
+++ b/lib/dominoCLI/ttypes.pyc
Binary files differ