2
2
3
3
Check up for QMK environment.
4
4
"""
5
- import shutil
6
- import platform
7
5
import os
6
+ import platform
7
+ import shutil
8
+ import subprocess
9
+ from glob import glob
8
10
9
11
from milc import cli
10
12
@@ -16,32 +18,44 @@ def main(cli):
16
18
This is currently very simple, it just checks that all the expected binaries are on your system.
17
19
18
20
TODO(unclaimed):
19
- * [ ] Run the binaries to make sure they work
20
21
* [ ] Compile a trivial program with each compiler
21
22
* [ ] Check for udev entries on linux
22
23
"""
23
24
24
25
binaries = ['dfu-programmer' , 'avrdude' , 'dfu-util' , 'avr-gcc' , 'arm-none-eabi-gcc' ]
26
+ binaries += glob ('bin/qmk-*' )
25
27
26
- cli .log .info ('QMK Doctor is Checking your environment' )
28
+ cli .log .info ('QMK Doctor is checking your environment' )
27
29
28
30
ok = True
29
31
for binary in binaries :
30
32
res = shutil .which (binary )
31
33
if res is None :
32
- cli .log .error (' {fg_red}QMK can\ ' t find ' + binary + ' in your path' )
34
+ cli .log .error (" {fg_red}QMK can't find %s in your path" , binary )
33
35
ok = False
36
+ else :
37
+ try :
38
+ subprocess .run ([binary , '--version' ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , timeout = 5 , check = True )
39
+ except subprocess .CalledProcessError :
40
+ cli .log .error ("{fg_red}Can't run `%s --version`" , binary )
41
+ ok = False
34
42
35
43
OS = platform .system ()
36
44
if OS == "Darwin" :
37
45
cli .log .info ("Detected {fg_cyan}macOS" )
38
46
elif OS == "Linux" :
39
47
cli .log .info ("Detected {fg_cyan}linux" )
40
- test = 'systemctl list-unit-files | grep enabled | grep -i ModemManager'
41
- if os .system (test ) == 0 :
42
- cli .log .warn ("{bg_yellow}Detected modem manager. Please disable it if you are using Pro Micros" )
48
+ if shutil .which ('systemctl' ):
49
+ test = 'systemctl list-unit-files | grep enabled | grep -i ModemManager'
50
+ if os .system (test ) == 0 :
51
+ cli .log .warn ("{bg_yellow}Detected modem manager. Please disable it if you are using Pro Micros" )
52
+ else :
53
+ cli .log .warn ("Can't find systemctl to check for ModemManager." )
43
54
else :
44
55
cli .log .info ("Assuming {fg_cyan}Windows" )
45
56
46
57
if ok :
47
58
cli .log .info ('{fg_green}QMK is ready to go' )
59
+ else :
60
+ cli .log .info ('{fg_yellow}Problems detected, please fix these problems before proceeding.' )
61
+ # FIXME(skullydazed): Link to a document about troubleshooting, or discord or something
0 commit comments