From db1eacdaacb9c8f6889f46bc1c6af155b81ad72a Mon Sep 17 00:00:00 2001 From: Zach White Date: Wed, 19 May 2021 15:24:46 -0700 Subject: 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 * fix the cpp invocation for older python * allow for unprompted installation * make sure qmk new-keyboard works on windows Co-authored-by: Ryan --- lib/python/qmk/submodules.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib/python/qmk/submodules.py') diff --git a/lib/python/qmk/submodules.py b/lib/python/qmk/submodules.py index be51a68043..6a272dae50 100644 --- a/lib/python/qmk/submodules.py +++ b/lib/python/qmk/submodules.py @@ -1,7 +1,6 @@ """Functions for working with QMK's submodules. """ - -import subprocess +from milc import cli def status(): @@ -18,7 +17,7 @@ def status(): status is None when the submodule doesn't exist, False when it's out of date, and True when it's current """ submodules = {} - git_cmd = subprocess.run(['git', 'submodule', 'status'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30, universal_newlines=True) + git_cmd = cli.run(['git', 'submodule', 'status'], timeout=30) for line in git_cmd.stdout.split('\n'): if not line: @@ -53,19 +52,19 @@ def update(submodules=None): # Update everything git_sync_cmd.append('--recursive') git_update_cmd.append('--recursive') - subprocess.run(git_sync_cmd, check=True) - subprocess.run(git_update_cmd, check=True) + cli.run(git_sync_cmd, check=True) + cli.run(git_update_cmd, check=True) else: if isinstance(submodules, str): # Update only a single submodule git_sync_cmd.append(submodules) git_update_cmd.append(submodules) - subprocess.run(git_sync_cmd, check=True) - subprocess.run(git_update_cmd, check=True) + cli.run(git_sync_cmd, check=True) + cli.run(git_update_cmd, check=True) else: # Update submodules in a list for submodule in submodules: - subprocess.run(git_sync_cmd + [submodule], check=True) - subprocess.run(git_update_cmd + [submodule], check=True) + cli.run([*git_sync_cmd, submodule], check=True) + cli.run([*git_update_cmd, submodule], check=True) -- cgit v1.2.3