8000 tools/mpremote: Remove non-existent COM0. · micropython/micropython@7d51239 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d51239

Browse files
committed
tools/mpremote: Remove non-existent COM0.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
1 parent c9ec427 commit 7d51239

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

tools/mpremote/mpremote/main.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -319,35 +319,34 @@ def argparse_none(description):
319319
"--version": "version",
320320
}
321321

322-
# Add "a0", "a1", ..., "u0", "u1", ..., "c0", "c1", ... as aliases
322+
# Add "a0", "a1", ..., "u0", "u1", ..., "c1", "c2", ... as aliases
323323
# for "connect /dev/ttyACMn" (and /dev/ttyUSBn, COMn) etc.
324324
for port_num in range(4):
325325
for prefix, port in [("a", "/dev/ttyACM"), ("u", "/dev/ttyUSB"), ("c", "COM")]:
326-
_BUILTIN_COMMAND_EXPANSIONS["{}{}".format(prefix, port_num)] = {
327-
"command": "connect {}{}".format(port, port_num),
328-
"help": 'connect to serial port "{}{}"'.format(port, port_num),
326+
if port_num == 0 and port == "COM":
327+
continue # skip COM0 as it does not exist
328+
_BUILTIN_COMMAND_EXPANSIONS[f"{prefix}{port_num}"] = {
329+
"command": f"connect {port}{port_num}",
330+
"help": f'connect to serial port "{port}{port_num}"',
329331
}
330332

331333

332334
def load_user_config():
333335
# Create empty config object.
334336
config = __build_class__(lambda: None, "Config")()
335337
config.commands = {}
336-
# use $XDG_CONFIG_HOME, if on Windows use $APPDATA
338+
# Get config file name.
337339
if os.name != "nt":
338-
# Get config file name.
339-
path = os.getenv("XDG_CONFIG_HOME")
340+
path = os.getenv("XDG_CONFIG_HOME") or os.getenv("HOME")
340341
if path is None:
341-
path = os.getenv("HOME")
342-
if path is None:
343-
return config
344-
path = os.path.join(path, ".config")
345-
path = os.path.join(path, _PROG)
342+
return config
343+
path = os.path.join(path, ".config")
346344
else:
347-
path = os.getenv("APPDATA")
345+
# HOME might be used by MSYS2, but APPDATA is the standard on Windows.
346+
path = os.getenv("HOME") or os.getenv("APPDATA")
348347
if path is None:
349348
return config
350-
path = os.path.join(path, _PROG)
349+
path = os.path.join(path, _PROG)
351350
config_file = os.path.join(path, "config.py")
352351
# Check if config file exists.
353352
if not os.path.exists(config_file):
@@ -363,7 +362,6 @@ def load_user_config():
363362
config.__dict__["__file__"] = config_file
364363
exec(config_data, config.__dict__)
365364
os.chdir(prev_cwd)
366-
367365
return config
368366

369367

0 commit comments

Comments
 (0)
0