diff options
author | Zach White <skullydazed@gmail.com> | 2021-05-19 15:24:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-19 15:24:46 -0700 |
commit | db1eacdaacb9c8f6889f46bc1c6af155b81ad72a (patch) | |
tree | cd32a69a04c7ff93a11941d82aef3ce31c2b7523 /lib/python/qmk/keymap.py | |
parent | a9aec546c873fa5a2cb1d9a10878aca71818b609 (diff) | |
download | qmk_firmware-db1eacdaacb9c8f6889f46bc1c6af155b81ad72a.tar.gz qmk_firmware-db1eacdaacb9c8f6889f46bc1c6af155b81ad72a.zip |
Align our subprocess usage with current best practices. (#12940)
* Align our subprocess usage with current best practices.
* remove unused import
* Apply suggestions from code review
Co-authored-by: Ryan <fauxpark@gmail.com>
* fix the cpp invocation for older python
* allow for unprompted installation
* make sure qmk new-keyboard works on windows
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'lib/python/qmk/keymap.py')
-rw-r--r-- | lib/python/qmk/keymap.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index 4ad9ffb59..ac7951082 100644 --- a/lib/python/qmk/keymap.py +++ b/lib/python/qmk/keymap.py | |||
@@ -1,9 +1,9 @@ | |||
1 | """Functions that help you work with QMK keymaps. | 1 | """Functions that help you work with QMK keymaps. |
2 | """ | 2 | """ |
3 | import json | 3 | import json |
4 | import subprocess | ||
5 | import sys | 4 | import sys |
6 | from pathlib import Path | 5 | from pathlib import Path |
6 | from subprocess import DEVNULL | ||
7 | 7 | ||
8 | import argcomplete | 8 | import argcomplete |
9 | from milc import cli | 9 | from milc import cli |
@@ -12,7 +12,6 @@ from pygments.token import Token | |||
12 | from pygments import lex | 12 | from pygments import lex |
13 | 13 | ||
14 | import qmk.path | 14 | import qmk.path |
15 | import qmk.commands | ||
16 | from qmk.keyboard import find_keyboard_from_dir, rules_mk | 15 | from qmk.keyboard import find_keyboard_from_dir, rules_mk |
17 | 16 | ||
18 | # The `keymap.c` template to use when a keyboard doesn't have its own | 17 | # The `keymap.c` template to use when a keyboard doesn't have its own |
@@ -361,7 +360,7 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa | |||
361 | return sorted(names) | 360 | return sorted(names) |
362 | 361 | ||
363 | 362 | ||
364 | def _c_preprocess(path, stdin=None): | 363 | def _c_preprocess(path, stdin=DEVNULL): |
365 | """ Run a file through the C pre-processor | 364 | """ Run a file through the C pre-processor |
366 | 365 | ||
367 | Args: | 366 | Args: |
@@ -371,7 +370,9 @@ def _c_preprocess(path, stdin=None): | |||
371 | Returns: | 370 | Returns: |
372 | the stdout of the pre-processor | 371 | the stdout of the pre-processor |
373 | """ | 372 | """ |
374 | pre_processed_keymap = qmk.commands.run(['cpp', path] if path else ['cpp'], stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) | 373 | cmd = ['cpp', str(path)] if path else ['cpp'] |
374 | pre_processed_keymap = cli.run(cmd, stdin=stdin) | ||
375 | |||
375 | return pre_processed_keymap.stdout | 376 | return pre_processed_keymap.stdout |
376 | 377 | ||
377 | 378 | ||