fix type error
This commit is contained in:
parent
c0f8caddfc
commit
6872800bba
1 changed files with 8 additions and 14 deletions
20
statusd.py
Normal file → Executable file
20
statusd.py
Normal file → Executable file
|
@ -236,18 +236,17 @@ def main():
|
||||||
try:
|
try:
|
||||||
mySocket.bind((config['server']['host'], int(config['server']['port'])))
|
mySocket.bind((config['server']['host'], int(config['server']['port'])))
|
||||||
mySocket.listen(5)
|
mySocket.listen(5)
|
||||||
logging.info('Listening on {} at Port {}'.format(config['server']['host'],
|
|
||||||
config['server']['port']))
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error('Unable to bind and listen')
|
logging.error('Unable to bind and listen')
|
||||||
logging.error('{}'.format(e))
|
logging.error('{}'.format(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
logging.info('Listening on {} at Port {}'.format(config['server']['host'],
|
||||||
|
config['server']['port']))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
fromSocket, fromAddr = mySocket.accept()
|
fromSocket, fromAddr = mySocket.accept()
|
||||||
logging.info('Client connected: {}:{}'.format(fromAddr[0], fromAddr[1]))
|
logging.info('Client connected: {}:{}'.format(fromAddr[0], fromAddr[1]))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fromSocket.settimeout(float(config['general']['timeout']))
|
fromSocket.settimeout(float(config['general']['timeout']))
|
||||||
logging.debug('Connection timeout set to {}'.format(
|
logging.debug('Connection timeout set to {}'.format(
|
||||||
|
@ -255,23 +254,18 @@ def main():
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.error('Cannot set timeout to {}'.format(
|
logging.error('Cannot set timeout to {}'.format(
|
||||||
config['general']['timeout']))
|
config['general']['timeout']))
|
||||||
logging.error('Using default value {}'.format(
|
|
||||||
config['general']['timeout']))
|
|
||||||
fromSocket.settimeout(config['general']['timeout'])
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn = context.wrap_socket(fromSocket, server_side=True)
|
conn = context.wrap_socket(fromSocket, server_side=True)
|
||||||
conn.settimeout(config['general']['timeout'])
|
conn.settimeout(float(config['general']['timeout']))
|
||||||
# display_peercert(conn.getpeercert())
|
except socket.timeout:
|
||||||
|
logging.error('Socket timeout')
|
||||||
|
except Exception as e:
|
||||||
|
logging.error('Connection failed: {}'.format(e))
|
||||||
logging.debug('Connection established')
|
logging.debug('Connection established')
|
||||||
logging.debug('Peer certificate commonName: {}'.format(
|
logging.debug('Peer certificate commonName: {}'.format(
|
||||||
conn.getpeercert()['subject'][5][0][1]))
|
conn.getpeercert()['subject'][5][0][1]))
|
||||||
logging.debug('Peer certificate serialNumber: {}'.format(
|
logging.debug('Peer certificate serialNumber: {}'.format(
|
||||||
conn.getpeercert()['serialNumber']))
|
conn.getpeercert()['serialNumber']))
|
||||||
except socket.timeout:
|
|
||||||
logging.error('Socket timeout')
|
|
||||||
except Exception as e:
|
|
||||||
logging.error('Connection failed: {}'.format(e))
|
|
||||||
|
|
||||||
raw_data = conn.recv(1)
|
raw_data = conn.recv(1)
|
||||||
if receive_buffer_is_valid(raw_data) is True:
|
if receive_buffer_is_valid(raw_data) is True:
|
||||||
|
|
Loading…
Reference in a new issue