diff options
author | lokher <lokher@gmail.com> | 2023-04-26 16:32:15 +0800 |
---|---|---|
committer | lokher <lokher@gmail.com> | 2023-04-26 16:32:15 +0800 |
commit | e4f4ceaf3f2e3d25fb282273a81f9b58790fc427 (patch) | |
tree | c0a257eab0ffe5238fdf2c04882e8ee1fe8fc46e /lib/python/qmk/cli/doctor/linux.py | |
parent | 103badc87cb50db1ff3851c84331e86ba78fb681 (diff) |
merge upstream 713427c
Diffstat (limited to 'lib/python/qmk/cli/doctor/linux.py')
-rw-r--r-- | lib/python/qmk/cli/doctor/linux.py | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/lib/python/qmk/cli/doctor/linux.py b/lib/python/qmk/cli/doctor/linux.py index a803305c0d..f0850d4e64 100644 --- a/lib/python/qmk/cli/doctor/linux.py +++ b/lib/python/qmk/cli/doctor/linux.py @@ -7,7 +7,11 @@ from pathlib import Path from milc import cli from qmk.constants import QMK_FIRMWARE, BOOTLOADER_VIDS_PIDS -from .check import CheckStatus +from .check import CheckStatus, release_info + + +def _is_wsl(): + return 'microsoft' in platform.uname().release.lower() def _udev_rule(vid, pid=None, *args): @@ -78,10 +82,13 @@ def check_udev_rules(): # Collect all rules from the config files for rule_file in udev_rules: - for line in rule_file.read_text(encoding='utf-8').split('\n'): - line = line.strip() - if not line.startswith("#") and len(line): - current_rules.add(line) + try: + for line in rule_file.read_text(encoding='utf-8').split('\n'): + line = line.strip() + if not line.startswith("#") and len(line): + current_rules.add(line) + except PermissionError: + cli.log.debug("Failed to read: %s", rule_file) # Check if the desired rules are among the currently present rules for bootloader, rules in desired_rules.items(): @@ -127,17 +134,22 @@ def check_modem_manager(): def os_test_linux(): """Run the Linux specific tests. """ - # Don't bother with udev on WSL, for now - if 'microsoft' in platform.uname().release.lower(): - cli.log.info("Detected {fg_cyan}Linux (WSL){fg_reset}.") + info = release_info() + release_id = info.get('PRETTY_NAME', info.get('ID', 'Unknown')) + plat = 'WSL, ' if _is_wsl() else '' + cli.log.info(f"Detected {{fg_cyan}}Linux ({plat}{release_id}){{fg_reset}}.") + + # Don't bother with udev on WSL, for now + if _is_wsl(): # https://github.com/microsoft/WSL/issues/4197 if QMK_FIRMWARE.as_posix().startswith("/mnt"): cli.log.warning("I/O performance on /mnt may be extremely slow.") return CheckStatus.WARNING - return CheckStatus.OK else: - cli.log.info("Detected {fg_cyan}Linux{fg_reset}.") + rc = check_udev_rules() + if rc != CheckStatus.OK: + return rc - return check_udev_rules() + return CheckStatus.OK |