From e4950be337df87875d3bb86fdae4ea0384163a14 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 15 Dec 2018 13:53:23 +0200 Subject: [PATCH] better handling of OTA address --- builder/main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/builder/main.py b/builder/main.py index d8846c5..a7af5c5 100644 --- a/builder/main.py +++ b/builder/main.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import re +import socket import sys from os.path import isfile, join @@ -296,9 +296,10 @@ if upload_protocol == "esptool": # Handle uploading via OTA ota_port = None if env.get("UPLOAD_PORT"): - ota_port = re.match( - r"\"?((([0-9]{1,3}\.){3}[0-9]{1,3})|.+\.local)\"?$", - env.get("UPLOAD_PORT")) + try: + ota_port = socket.gethostbyname(env.get("UPLOAD_PORT")) + except socket.error: + pass if ota_port: env.Replace(UPLOADCMD="$UPLOADOTACMD")