summaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2023-01-19 10:25:47 +0000
committerGitHub <noreply@github.com>2023-01-19 10:25:47 +0000
commit4973950ddcef28d94a1fc589951e024a91a240d7 (patch)
treea52fba64d5198fc219fc201ac286dd97aa7458b9 /lib/python
parent3723c0e3d57f0afdff0e1b7421d26d6c7f6c980d (diff)
Print distro in doctor output (#19633)
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/qmk/cli/doctor/check.py18
-rw-r--r--lib/python/qmk/cli/doctor/linux.py23
-rw-r--r--lib/python/qmk/cli/doctor/windows.py8
3 files changed, 41 insertions, 8 deletions
diff --git a/lib/python/qmk/cli/doctor/check.py b/lib/python/qmk/cli/doctor/check.py
index 426876e98a..cd69cdd11c 100644
--- a/lib/python/qmk/cli/doctor/check.py
+++ b/lib/python/qmk/cli/doctor/check.py
@@ -158,3 +158,21 @@ def is_executable(command):
cli.log.error("{fg_red}Can't run `%s %s`", command, version_arg)
return False
+
+
+def release_info(file='/etc/os-release'):
+ """Parse release info to dict
+ """
+ ret = {}
+ try:
+ with open(file) as f:
+ for line in f:
+ if '=' in line:
+ key, value = map(str.strip, line.split('=', 1))
+ if value.startswith('"') and value.endswith('"'):
+ value = value[1:-1]
+ ret[key] = value
+ except (PermissionError, FileNotFoundError):
+ pass
+
+ return ret
diff --git a/lib/python/qmk/cli/doctor/linux.py b/lib/python/qmk/cli/doctor/linux.py
index 95bafe8c64..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):
@@ -130,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
diff --git a/lib/python/qmk/cli/doctor/windows.py b/lib/python/qmk/cli/doctor/windows.py
index 381ab36fde..26bb65374b 100644
--- a/lib/python/qmk/cli/doctor/windows.py
+++ b/lib/python/qmk/cli/doctor/windows.py
@@ -2,7 +2,7 @@ import platform
from milc import cli
-from .check import CheckStatus
+from .check import CheckStatus, release_info
def os_test_windows():
@@ -11,4 +11,10 @@ def os_test_windows():
win32_ver = platform.win32_ver()
cli.log.info("Detected {fg_cyan}Windows %s (%s){fg_reset}.", win32_ver[0], win32_ver[1])
+ # MSYS really does not like "/" files - resolve manually
+ file = cli.run(['cygpath', '-m', '/etc/qmk-release']).stdout.strip()
+ qmk_distro_version = release_info(file).get('VERSION', None)
+ if qmk_distro_version:
+ cli.log.info('QMK MSYS version: %s', qmk_distro_version)
+
return CheckStatus.OK