diff options
Diffstat (limited to 'lib/python/qmk/commands.py')
-rw-r--r-- | lib/python/qmk/commands.py | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 8c3f95ea2..ee049e8af 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py | |||
@@ -2,11 +2,9 @@ | |||
2 | """ | 2 | """ |
3 | import json | 3 | import json |
4 | import os | 4 | import os |
5 | import platform | ||
6 | import subprocess | ||
7 | import shlex | ||
8 | import shutil | 5 | import shutil |
9 | from pathlib import Path | 6 | from pathlib import Path |
7 | from subprocess import DEVNULL | ||
10 | from time import strftime | 8 | from time import strftime |
11 | 9 | ||
12 | from milc import cli | 10 | from milc import cli |
@@ -94,7 +92,7 @@ def get_git_version(repo_dir='.', check_dir='.'): | |||
94 | git_describe_cmd = ['git', 'describe', '--abbrev=6', '--dirty', '--always', '--tags'] | 92 | git_describe_cmd = ['git', 'describe', '--abbrev=6', '--dirty', '--always', '--tags'] |
95 | 93 | ||
96 | if Path(check_dir).exists(): | 94 | if Path(check_dir).exists(): |
97 | git_describe = cli.run(git_describe_cmd, cwd=repo_dir) | 95 | git_describe = cli.run(git_describe_cmd, stdin=DEVNULL, cwd=repo_dir) |
98 | 96 | ||
99 | if git_describe.returncode == 0: | 97 | if git_describe.returncode == 0: |
100 | return git_describe.stdout.strip() | 98 | return git_describe.stdout.strip() |
@@ -224,20 +222,3 @@ def parse_configurator_json(configurator_file): | |||
224 | user_keymap['layout'] = aliases[orig_keyboard]['layouts'][user_keymap['layout']] | 222 | user_keymap['layout'] = aliases[orig_keyboard]['layouts'][user_keymap['layout']] |
225 | 223 | ||
226 | return user_keymap | 224 | return user_keymap |
227 | |||
228 | |||
229 | def run(command, *args, **kwargs): | ||
230 | """Run a command with subprocess.run | ||
231 | """ | ||
232 | platform_id = platform.platform().lower() | ||
233 | |||
234 | if isinstance(command, str): | ||
235 | raise TypeError('`command` must be a non-text sequence such as list or tuple.') | ||
236 | |||
237 | if 'windows' in platform_id: | ||
238 | safecmd = map(str, command) | ||
239 | safecmd = map(shlex.quote, safecmd) | ||
240 | safecmd = ' '.join(safecmd) | ||
241 | command = [os.environ.get('SHELL', '/usr/bin/bash'), '-c', safecmd] | ||
242 | |||
243 | return subprocess.run(command, *args, **kwargs) | ||