diff options
author | Ulas Kozat <ulas.kozat@gmail.com> | 2016-06-15 11:56:45 -0700 |
---|---|---|
committer | Ulas Kozat <ulas.kozat@gmail.com> | 2016-06-15 11:56:45 -0700 |
commit | 28dc1f7574e1fdd2fbfd49feec3dcc559c43ad04 (patch) | |
tree | 445d084ce8950b12320ce8755a634b806b633d10 | |
parent | d9a5837b612db8eb8405e80f591ba3416b16f96a (diff) |
Minor bug fixes for (1) registration timeout and (2) handling domino server IP passed via CLI
Change-Id: I339c6e4ae25d922ba85a8d9e439207e0eeab9450
Signed-off-by: Ulas Kozat <ulas.kozat@gmail.com>
-rwxr-xr-x | DominoClient.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/DominoClient.py b/DominoClient.py index 19aaa65..b05f0fb 100755 --- a/DominoClient.py +++ b/DominoClient.py @@ -46,18 +46,9 @@ class CommunicationHandler: def __init__(self, dominoclient): self.log = {} self.dominoClient = dominoclient - try: - # Make socket - transport = TSocket.TSocket(DOMINO_SERVER_IP, DOMINO_SERVER_PORT) - transport.setTimeout(THRIFT_RPC_TIMEOUT_MS) - # Add buffering to compensate for slow raw sockets - self.transport = TTransport.TBufferedTransport(transport) - # Wrap in a protocol - self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport) - # Create a client to use the protocol encoder - self.sender = Communication.Client(self.protocol) - except Thrift.TException, tx: - logging.error('%s' , tx.message) + self.transport = None + self.protocol = None + self.sender = None # Template Push from Domino Server is received # Actions: @@ -110,7 +101,19 @@ class CommunicationHandler: def openconnection(self): - self.transport.open() + try: + # Make socket + transport = TSocket.TSocket(self.dominoClient.dominoserver_IP, DOMINO_SERVER_PORT) + transport.setTimeout(THRIFT_RPC_TIMEOUT_MS) + # Add buffering to compensate for slow raw sockets + self.transport = TTransport.TBufferedTransport(transport) + # Wrap in a protocol + self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport) + # Create a client to use the protocol encoder + self.sender = Communication.Client(self.protocol) + self.transport.open() + except Thrift.TException, tx: + logging.error('%s' , tx.message) def closeconnection(): self.transport.close() @@ -228,6 +231,8 @@ class DominoClientCLIService(threading.Thread): class DominoClient: def __init__(self): + + self.communicationHandler = CommunicationHandler(self) self.processor = None self.transport = None @@ -238,8 +243,7 @@ class DominoClient: self.CLIservice = None self.serviceport = 9091 - self.dominoserver_IP = 'localhost' - + self.dominoserver_IP = DOMINO_SERVER_IP self.CLIport = DOMINO_CLI_PORT #Start from UNREGISTERED STATE @@ -292,7 +296,7 @@ class DominoClient: except (Thrift.TException, TSocket.TTransportException) as tx: logging.error('%s' , tx.message) except (socket.timeout) as tx: - self.dominoclient.handle_RPC_timeout(pub_msg) + self.handle_RPC_timeout(reg_msg) except (socket.error) as tx: logging.error('%s' , tx.message) self.seqno = self.seqno + 1 |