Better handling of upload port for OTA // Issue #417

This commit is contained in:
Ivan Kravets
2015-12-30 19:01:26 +02:00
parent f2cad66d79
commit 7a91683ca6
2 changed files with 8 additions and 12 deletions

View File

@@ -14,7 +14,7 @@
import sys import sys
VERSION = (2, 7, "0.dev12") VERSION = (2, 7, "0.dev13")
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio" __title__ = "platformio"

View File

@@ -19,7 +19,6 @@
""" """
import re import re
import socket
from os.path import join from os.path import join
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
@@ -116,7 +115,7 @@ env.Replace(
UPLOADEROTAFLAGS=[ UPLOADEROTAFLAGS=[
"--debug", "--debug",
"--progress", "--progress",
"-i", '"$UPLOAD_PORT"', "-i", "$UPLOAD_PORT",
"$UPLOAD_FLAGS" "$UPLOAD_FLAGS"
], ],
@@ -230,15 +229,12 @@ if "FRAMEWORK" in env:
) )
# Handle uploading via OTA # Handle uploading via OTA
try: ota_port = None
if (env.get("UPLOAD_PORT") and ( if env.get("UPLOAD_PORT"):
env.get("UPLOAD_PORT").endswith(".local") or ota_port = re.match(r"((([0-9]{1,3}\.){3}[0-9]{1,3})|.+\.local)$",
socket.inet_aton(env.get("UPLOAD_PORT")))): env.get("UPLOAD_PORT"))
env.Replace( if ota_port:
UPLOADCMD="$UPLOADOTACMD" env.Replace(UPLOADCMD="$UPLOADOTACMD")
)
except socket.error:
pass
# Configure native SDK # Configure native SDK
else: else: