stability improvements for ip daemon
This commit is contained in:
parent
eafad7ccdb
commit
0f95d4207a
1 changed files with 13 additions and 7 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import datetime
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import threading
|
import threading
|
||||||
|
@ -47,7 +48,7 @@ def get_ip():
|
||||||
s.connect(('10.255.255.255', 1))
|
s.connect(('10.255.255.255', 1))
|
||||||
IP = s.getsockname()[0]
|
IP = s.getsockname()[0]
|
||||||
except Exception:
|
except Exception:
|
||||||
IP = '127.0.0.1'
|
IP = 'Not connected'
|
||||||
print(f"Error could not query ip: {e}")
|
print(f"Error could not query ip: {e}")
|
||||||
finally:
|
finally:
|
||||||
s.close()
|
s.close()
|
||||||
|
@ -56,12 +57,17 @@ def get_ip():
|
||||||
|
|
||||||
def write_ip_to_screen():
|
def write_ip_to_screen():
|
||||||
while os.getenv("IP_OUTPUT", "true") == "true":
|
while os.getenv("IP_OUTPUT", "true") == "true":
|
||||||
ip = str(get_ip())
|
try:
|
||||||
print(f"writing {ip} to display")
|
ip = str(get_ip())
|
||||||
Logging.get_logger().info(f"writing {ip} to display")
|
print(f"writing {ip} to display")
|
||||||
Display.write(1, "Current IP:")
|
Logging.get_logger().info(f"writing {ip} to display")
|
||||||
Display.write(2, ip)
|
Display.write(1, "Current IP:")
|
||||||
time.sleep(5)
|
Display.write(2, ip)
|
||||||
|
Display.write(3, datetime.datetime.now().strftime("%b %d %Y %H:%M:%S"))
|
||||||
|
time.sleep(5)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Exception in write ip thread: {e}")
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Reference in a new issue