def get_serialports():
    try:
        from serial.tools.list_ports import comports
    except ImportError:
        raise exception.GetSerialPortsError(os.name)

    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.*"):
            result.append({"port": p, "description": "", "hwid": ""})
    return result
dataset/ETHPy150Open platformio/platformio/platformio/util.py/get_serialports/original