Skip to content

Commit

Permalink
Workaround failure to import pyserial list_ports on MacOS Big Sur Pre…
Browse files Browse the repository at this point in the history
…view

References:
#540
pyserial/pyserial#509

The fix will probably come in a Python update before the Big Sur final release,
there is a bundle of PRs including an apparent fix for the underlying issue here:
https://bugs.python.org/issue41100
  • Loading branch information
projectgus committed Aug 26, 2020
1 parent 15e6ae3 commit cb2060c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions esptool.py
Expand Up @@ -60,6 +60,13 @@
print("The installed version (%s) of pyserial appears to be too old for esptool.py (Python interpreter %s). "
"Check the README for installation instructions." % (sys.VERSION, sys.executable))
raise
except Exception:
if sys.platform == "darwin":
# swallow the exception, this is a known issue in pyserial+macOS Big Sur preview ref https://github.com/espressif/esptool/issues/540
list_ports = None
else:
raise


__version__ = "3.0-dev"

Expand Down Expand Up @@ -3309,6 +3316,9 @@ def add_spi_flash_subparsers(parent, is_elf2image):
initial_baud = args.baud

if args.port is None:
if list_ports is None:
raise FatalError("Listing all serial ports is currently not available on this operating system version. "
"Specify the port when running esptool.py")
ser_list = sorted(ports.device for ports in list_ports.comports())
print("Found %d serial ports" % len(ser_list))
else:
Expand Down

0 comments on commit cb2060c

Please sign in to comment.