From 7702cb2c7eef47500df93a036e494433a4f7dada Mon Sep 17 00:00:00 2001 From: marcsello Date: Wed, 22 Apr 2020 05:01:17 +0200 Subject: [PATCH] fixed confusing logging --- app.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index b3aa767..9a6848b 100644 --- a/app.py +++ b/app.py @@ -78,19 +78,20 @@ def main(): # Test ip change stuff - current_ip = r.get('current_ip') + old_ip = r.get('current_ip') - if current_ip: - current_ip = current_ip.decode('utf-8') + if old_ip: + 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')) logging.debug(f"Previous info about the ip address could not be found! Current: {current_ip}") - elif current_ip != socket.gethostbyname(host_name): - logging.info(f'IP changed: {current_ip} Pushing updates...') - current_ip = socket.gethostbyname(host_name) + elif old_ip != current_ip: + logging.info(f'IP changed: {old_ip} -> {current_ip} Pushing updates...') r.set('current_ip', current_ip.encode('utf-8')) # pushing updates...