summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/doctor/linux.py
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2023-02-28 11:22:29 +1100
committerNick Brassel <nick@tzarc.org>2023-02-28 11:22:29 +1100
commitbacec14073b2e897d5a52caf12de5a6a1f7b4078 (patch)
treed4e3e57aac1a829a191831efd2e62c8a43217885 /lib/python/qmk/cli/doctor/linux.py
parentd70e9b8659a7fbbd7069fd542bd07e67e04327a1 (diff)
parentb865b9e1706ad28ae4882bd2e0331e98808295fa (diff)
Merge remote-tracking branch 'upstream/develop'
Diffstat (limited to 'lib/python/qmk/cli/doctor/linux.py')
-rw-r--r--lib/python/qmk/cli/doctor/linux.py34
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