diff options
author | Erovia <erovia@users.noreply.github.com> | 2019-11-07 19:53:03 +0100 |
---|---|---|
committer | skullydazed <skullydazed@users.noreply.github.com> | 2020-01-11 12:18:30 -0800 |
commit | 8f47e62b36cae15f989aaaa93caf05d4de258fb7 (patch) | |
tree | 52004e7cac337ae133d095921e8497931d8786af /lib/python | |
parent | e905d86fc5ba839595ba8472f99f74250b053a47 (diff) | |
download | qmk_firmware-8f47e62b36cae15f989aaaa93caf05d4de258fb7.tar.gz qmk_firmware-8f47e62b36cae15f989aaaa93caf05d4de258fb7.zip |
Make the udev rules easier to read and manage
Diffstat (limited to 'lib/python')
-rwxr-xr-x | lib/python/qmk/cli/doctor.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/python/qmk/cli/doctor.py b/lib/python/qmk/cli/doctor.py index 80bd013b2..28bf57a7d 100755 --- a/lib/python/qmk/cli/doctor.py +++ b/lib/python/qmk/cli/doctor.py | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | Check up for QMK environment. | 3 | Check up for QMK environment. |
4 | """ | 4 | """ |
5 | import os | ||
5 | import platform | 6 | import platform |
6 | import shutil | 7 | import shutil |
7 | import subprocess | 8 | import subprocess |
@@ -9,6 +10,13 @@ import glob | |||
9 | 10 | ||
10 | from milc import cli | 11 | from milc import cli |
11 | 12 | ||
13 | def _udev_rule(vid, pid = None): | ||
14 | """ Helper function that return udev rules | ||
15 | """ | ||
16 | if pid: | ||
17 | return 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="%s", ATTRS{idProduct}=="%s", MODE:="0666"' % (vid, pid) | ||
18 | else: | ||
19 | return 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="%s", MODE:="0666"' % vid | ||
12 | 20 | ||
13 | @cli.subcommand('Basic QMK environment checks') | 21 | @cli.subcommand('Basic QMK environment checks') |
14 | def doctor(cli): | 22 | def doctor(cli): |
@@ -18,7 +26,6 @@ def doctor(cli): | |||
18 | 26 | ||
19 | TODO(unclaimed): | 27 | TODO(unclaimed): |
20 | * [ ] Compile a trivial program with each compiler | 28 | * [ ] Compile a trivial program with each compiler |
21 | * [ ] Check for udev entries on linux | ||
22 | """ | 29 | """ |
23 | cli.log.info('QMK Doctor is checking your environment.') | 30 | cli.log.info('QMK Doctor is checking your environment.') |
24 | 31 | ||
@@ -50,15 +57,17 @@ def doctor(cli): | |||
50 | # Checking for udev rules | 57 | # Checking for udev rules |
51 | udev_dir = "/etc/udev/rules.d/" | 58 | udev_dir = "/etc/udev/rules.d/" |
52 | # These are the recommended udev rules | 59 | # These are the recommended udev rules |
53 | desired_rules = {"dfu": {'SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff4", MODE:="0666"', | 60 | desired_rules = dict(dfu = {_udev_rule("03eb", "2ff4"),_udev_rule("03eb", "2ffb"), _udev_rule("03eb", "2ff0")}, |
54 | 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ffb", MODE:="0666"', | 61 | |
55 | 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff0", MODE:="0666"'}, | 62 | tmk = {_udev_rule("feed")}, |
56 | "tmk": {'SUBSYSTEMS=="usb", ATTRS{idVendor}=="feed", MODE:="0666"'}, | 63 | |
57 | "input-club": {'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c11", MODE:="0666"'}, | 64 | input_club = {_udev_rule("1c11")}, |
58 | "stm32": {'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1eaf", ATTRS{idProduct}=="0003", MODE:="0666"', | 65 | |
59 | 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE:="0666"'}, | 66 | stm32 = {_udev_rule("1eaf", "0003"),_udev_rule("0483", "df11")}, |
60 | "caterina": {'ATTRS{idVendor}=="2a03", ENV{ID_MM_DEVICE_IGNORE}="1"', | 67 | |
61 | 'ATTRS{idVendor}=="2341", ENV{ID_MM_DEVICE_IGNORE}="1"'}} | 68 | caterina = {'ATTRS{idVendor}=="2a03", ENV{ID_MM_DEVICE_IGNORE}="1"', |
69 | 'ATTRS{idVendor}=="2341", ENV{ID_MM_DEVICE_IGNORE}="1"'} | ||
70 | ) | ||
62 | if os.path.exists(udev_dir): | 71 | if os.path.exists(udev_dir): |
63 | udev_rules = [rule for rule in glob.iglob(os.path.join(udev_dir, "*.rules")) if os.path.isfile(rule)] | 72 | udev_rules = [rule for rule in glob.iglob(os.path.join(udev_dir, "*.rules")) if os.path.isfile(rule)] |
64 | # Collect all rules from the config files | 73 | # Collect all rules from the config files |