Fix error with unicode for serial ports description

This commit is contained in:
Ivan Kravets
2016-01-26 20:30:45 +02:00
parent 9ede9d3c6d
commit ec19341e05
2 changed files with 13 additions and 4 deletions

View File

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

View File

@ -272,9 +272,18 @@ def get_serialports():
from serial.tools.list_ports import comports
except ImportError:
raise exception.GetSerialPortsError(os.name)
result = [{"port": p, "description": unicode(d, errors='ignore'),
"hwid": h}
for p, d, h in comports() if p]
result = []
for p, d, h in comports():
if not p:
continue
if "windows" in get_systype():
try:
d = unicode(d, errors="ignore")
except TypeError:
pass
result.append({"port": p, "description": d, "hwid": h})
# fix for PySerial
if not result and system() == "Darwin":
for p in glob("/dev/tty.*"):