From 7a91683ca65b62533d4492f991fba9f9609578e8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 30 Dec 2015 19:01:26 +0200 Subject: [PATCH] Better handling of upload port for OTA // Issue #417 --- platformio/__init__.py | 2 +- platformio/builder/scripts/espressif.py | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 2aac70cf..85dac650 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (2, 7, "0.dev12") +VERSION = (2, 7, "0.dev13") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index 2d5b2023..93b316fc 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -19,7 +19,6 @@ """ import re -import socket from os.path import join from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, @@ -116,7 +115,7 @@ env.Replace( UPLOADEROTAFLAGS=[ "--debug", "--progress", - "-i", '"$UPLOAD_PORT"', + "-i", "$UPLOAD_PORT", "$UPLOAD_FLAGS" ], @@ -230,15 +229,12 @@ if "FRAMEWORK" in env: ) # Handle uploading via OTA - try: - if (env.get("UPLOAD_PORT") and ( - env.get("UPLOAD_PORT").endswith(".local") or - socket.inet_aton(env.get("UPLOAD_PORT")))): - env.Replace( - UPLOADCMD="$UPLOADOTACMD" - ) - except socket.error: - pass + 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")) + if ota_port: + env.Replace(UPLOADCMD="$UPLOADOTACMD") # Configure native SDK else: