1
0
Fork 0

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>
This commit is contained in:
Zach White 2021-05-19 15:24:46 -07:00 committed by GitHub
parent a9aec546c8
commit db1eacdaac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 70 additions and 78 deletions

View file

@ -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)