From bc7aa60a30101f11fc03da84f18a2d029f2d30d6 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Sat, 11 Mar 2017 09:07:25 +0200 Subject: [PATCH] Catch exception if host is not found --- tools/espota.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/espota.py b/tools/espota.py index e09c9f12..eb809943 100755 --- a/tools/espota.py +++ b/tools/espota.py @@ -98,7 +98,14 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm inv_trys += 1 sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) remote_address = (remoteAddr, int(remotePort)) - sent = sock2.sendto(message.encode(), remote_address) + try: + sent = sock2.sendto(message.encode(), remote_address) + except: + sys.stderr.write('failed\n') + sys.stderr.flush() + sock2.close() + logging.error('Host %s Not Found', remoteAddr) + return 1 sock2.settimeout(1) try: data = sock2.recv(37).decode()