fixed confusing logging
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2020-04-22 05:01:17 +02:00
parent d32db92bab
commit 7702cb2c7e

17
app.py
View File

@ -78,19 +78,20 @@ def main():
# Test ip change stuff # Test ip change stuff
current_ip = r.get('current_ip') old_ip = r.get('current_ip')
if current_ip: if old_ip:
current_ip = current_ip.decode('utf-8') old_ip = old_ip.decode('utf-8')
if not current_ip: # Not set yet. I this case no update required current_ip = socket.gethostbyname(host_name)
current_ip = socket.gethostbyname(host_name)
if not old_ip: # Not set yet. I this case no update required
r.set('current_ip', current_ip.encode('utf-8')) r.set('current_ip', current_ip.encode('utf-8'))
logging.debug(f"Previous info about the ip address could not be found! Current: {current_ip}") logging.debug(f"Previous info about the ip address could not be found! Current: {current_ip}")
elif current_ip != socket.gethostbyname(host_name): elif old_ip != current_ip:
logging.info(f'IP changed: {current_ip} Pushing updates...') logging.info(f'IP changed: {old_ip} -> {current_ip} Pushing updates...')
current_ip = socket.gethostbyname(host_name)
r.set('current_ip', current_ip.encode('utf-8')) r.set('current_ip', current_ip.encode('utf-8'))
# pushing updates... # pushing updates...