fix bug in api file

replace strings with boolean and integer
This commit is contained in:
+++ 2020-11-22 22:35:27 +01:00
parent 64937e7ea9
commit d610db0d1f

View file

@ -155,11 +155,11 @@ def set_values(raw_data):
param 1: byte param 1: byte
return: tuple return: tuple
''' '''
status = "true" if raw_data == b'\x01' else "false" status = True if raw_data == b'\x01' else False
timestamp = str(time()).split('.')[0] timestamp = int(str(time()).split('.')[0])
logging.debug('Set values for timestamp: {} and status: {}'.format( logging.debug('Set values for timestamp: {} and status: {}'.format(
timestamp, status)) str(timestamp), str(status)))
return (status, timestamp) return (status, timestamp)
@ -235,7 +235,7 @@ def main():
logging.debug('Socket created') logging.debug('Socket created')
mySocket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) mySocket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
keep = mySocket.getsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE) keep = mySocket.getsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE)
logging.debug('Socket keepalive: {}'format(keep)) logging.debug('Socket keepalive: {}'.format(keep))
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)