Skip to content

Commit 54cd0fb

Browse files
dvvivankravets
authored andcommitted
Branch for espota if port resolved (platformio#97)
* Branch for espota if port resolved ESP_0CE07E is perfectly valid host name in intranet but when uploading it is treated as serial port. Proposed is to try explicitly network-resolve provided port. If this is not welcome, I believe it's easier and more robust to compose regexp for known serial ports, or use serial port list fetched from system (`util.get_serial_ports()`?) * Update main.py
1 parent d4fb3dd commit 54cd0fb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

builder/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# pylint: disable=redefined-outer-name
1616

1717
import re
18+
import socket
1819
from os.path import join
1920

2021

@@ -261,9 +262,10 @@ def _update_max_upload_size(env):
261262
# Handle uploading via OTA
262263
ota_port = None
263264
if env.get("UPLOAD_PORT"):
264-
ota_port = re.match(
265-
r"\"?((([0-9]{1,3}\.){3}[0-9]{1,3})|[^\\/]+\.[^\\/]+)\"?$",
266-
env.get("UPLOAD_PORT"))
265+
try:
266+
ota_port = socket.gethostbyname(env.get("UPLOAD_PORT"))
267+
except socket.error:
268+
pass
267269
if ota_port:
268270
env.Replace(UPLOADCMD="$UPLOADOTACMD")
269271

0 commit comments

Comments
 (0)