fix type error
This commit is contained in:
parent
c0f8caddfc
commit
6872800bba
1 changed files with 8 additions and 14 deletions
22
statusd.py
Normal file → Executable file
22
statusd.py
Normal file → Executable file
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue