From 6872800bba26c7ccc1756494b55c6760256d73e1 Mon Sep 17 00:00:00 2001 From: berhsi Date: Thu, 9 Jul 2020 16:09:14 +0200 Subject: [PATCH] fix type error --- statusd.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) mode change 100644 => 100755 statusd.py diff --git a/statusd.py b/statusd.py old mode 100644 new mode 100755 index babf749..29f9aa6 --- a/statusd.py +++ b/statusd.py @@ -236,18 +236,17 @@ def main(): try: mySocket.bind((config['server']['host'], int(config['server']['port']))) mySocket.listen(5) - logging.info('Listening on {} at Port {}'.format(config['server']['host'], - config['server']['port'])) except Exception as e: logging.error('Unable to bind and listen') logging.error('{}'.format(e)) sys.exit(1) + logging.info('Listening on {} at Port {}'.format(config['server']['host'], + config['server']['port'])) while True: try: fromSocket, fromAddr = mySocket.accept() logging.info('Client connected: {}:{}'.format(fromAddr[0], fromAddr[1])) - try: fromSocket.settimeout(float(config['general']['timeout'])) logging.debug('Connection timeout set to {}'.format( @@ -255,23 +254,18 @@ def main(): except Exception: logging.error('Cannot set timeout to {}'.format( config['general']['timeout'])) - logging.error('Using default value {}'.format( - config['general']['timeout'])) - fromSocket.settimeout(config['general']['timeout']) - try: conn = context.wrap_socket(fromSocket, server_side=True) - conn.settimeout(config['general']['timeout']) - # display_peercert(conn.getpeercert()) - logging.debug('Connection established') - logging.debug('Peer certificate commonName: {}'.format( - conn.getpeercert()['subject'][5][0][1])) - logging.debug('Peer certificate serialNumber: {}'.format( - conn.getpeercert()['serialNumber'])) + conn.settimeout(float(config['general']['timeout'])) except socket.timeout: logging.error('Socket timeout') except Exception as e: logging.error('Connection failed: {}'.format(e)) + logging.debug('Connection established') + logging.debug('Peer certificate commonName: {}'.format( + conn.getpeercert()['subject'][5][0][1])) + logging.debug('Peer certificate serialNumber: {}'.format( + conn.getpeercert()['serialNumber'])) raw_data = conn.recv(1) if receive_buffer_is_valid(raw_data) is True: