From e7b3af5c224eb153b0221dd4f6ebd59421b80038 Mon Sep 17 00:00:00 2001 From: Artwork1 Date: Fri, 5 Jan 2018 00:17:03 +0100 Subject: [PATCH] Fix no network crash --- scan_faces.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scan_faces.py b/scan_faces.py index 76f54e7..6a234e6 100755 --- a/scan_faces.py +++ b/scan_faces.py @@ -35,7 +35,11 @@ lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, # ip if config is needed over ssh. Username pi, Password: artwork1 -ip = (([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")] or [[(s.connect(("8.8.8.8", 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) + ["no IP found"])[0] +try: + ip = (([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")] or [[(s.connect(("8.8.8.8", 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) + ["no IP found"])[0] +except Exception: + ip = "No network" + lcd.clear() lcd.message("Init scanner.\n{}".format(ip) ) time.sleep(6) # give some time to read the ip.