summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/cli')
-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):
158 158
159 cli.log.error("{fg_red}Can't run `%s %s`", command, version_arg) 159 cli.log.error("{fg_red}Can't run `%s %s`", command, version_arg)
160 return False 160 return False
161
162
163def release_info(file='/etc/os-release'):
164 """Parse release info to dict
165 """
166 ret = {}
167 try:
168 with open(file) as f:
169 for line in f:
170 if '=' in line:
171 key, value = map(str.strip, line.split('=', 1))
172 if value.startswith('"') and value.endswith('"'):
173 value = value[1:-1]
174 ret[key] = value
175 except (PermissionError, FileNotFoundError):
176 pass
177
178 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
7from milc import cli 7from milc import cli
8 8
9from qmk.constants import QMK_FIRMWARE, BOOTLOADER_VIDS_PIDS 9from qmk.constants import QMK_FIRMWARE, BOOTLOADER_VIDS_PIDS
10from .check import CheckStatus 10from .check import CheckStatus, release_info
11
12
13def _is_wsl():
14 return 'microsoft' in platform.uname().release.lower()
11 15
12 16
13def _udev_rule(vid, pid=None, *args): 17def _udev_rule(vid, pid=None, *args):
@@ -130,17 +134,22 @@ def check_modem_manager():
130def os_test_linux(): 134def os_test_linux():
131 """Run the Linux specific tests. 135 """Run the Linux specific tests.
132 """ 136 """
133 # Don't bother with udev on WSL, for now 137 info = release_info()
134 if 'microsoft' in platform.uname().release.lower(): 138 release_id = info.get('PRETTY_NAME', info.get('ID', 'Unknown'))
135 cli.log.info("Detected {fg_cyan}Linux (WSL){fg_reset}.") 139 plat = 'WSL, ' if _is_wsl() else ''
136 140
141 cli.log.info(f"Detected {{fg_cyan}}Linux ({plat}{release_id}){{fg_reset}}.")
142
143 # Don't bother with udev on WSL, for now
144 if _is_wsl():
137 # https://github.com/microsoft/WSL/issues/4197 145 # https://github.com/microsoft/WSL/issues/4197
138 if QMK_FIRMWARE.as_posix().startswith("/mnt"): 146 if QMK_FIRMWARE.as_posix().startswith("/mnt"):
139 cli.log.warning("I/O performance on /mnt may be extremely slow.") 147 cli.log.warning("I/O performance on /mnt may be extremely slow.")
140 return CheckStatus.WARNING 148 return CheckStatus.WARNING
141 149
142 return CheckStatus.OK
143 else: 150 else:
144 cli.log.info("Detected {fg_cyan}Linux{fg_reset}.") 151 rc = check_udev_rules()
152 if rc != CheckStatus.OK:
153 return rc
145 154
146 return check_udev_rules() 155 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
2 2
3from milc import cli 3from milc import cli
4 4
5from .check import CheckStatus 5from .check import CheckStatus, release_info
6 6
7 7
8def os_test_windows(): 8def os_test_windows():
@@ -11,4 +11,10 @@ def os_test_windows():
11 win32_ver = platform.win32_ver() 11 win32_ver = platform.win32_ver()
12 cli.log.info("Detected {fg_cyan}Windows %s (%s){fg_reset}.", win32_ver[0], win32_ver[1]) 12 cli.log.info("Detected {fg_cyan}Windows %s (%s){fg_reset}.", win32_ver[0], win32_ver[1])
13 13
14 # MSYS really does not like "/" files - resolve manually
15 file = cli.run(['cygpath', '-m', '/etc/qmk-release']).stdout.strip()
16 qmk_distro_version = release_info(file).get('VERSION', None)
17 if qmk_distro_version:
18 cli.log.info('QMK MSYS version: %s', qmk_distro_version)
19
14 return CheckStatus.OK 20 return CheckStatus.OK