diff options
author | George Burgess IV <gbiv@google.com> | 2022-09-06 15:19:39 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-07 21:15:12 +0000 |
commit | 6cb38a6c19295fd4db8db03046cb819eba217dae (patch) | |
tree | e386aaed45770f96974243ef90aceee31cf14ab3 | |
parent | c0041a9550814e402f661a560855ff99863cffb2 (diff) | |
download | toolchain-utils-6cb38a6c19295fd4db8db03046cb819eba217dae.tar.gz |
check-presubmit: use subprocess.run
Fixing feedback from crrev.com/c/3877334, which isn't strictly related
to that change, but is still useful to clean up
BUG=None
TEST=`repo upload`
Change-Id: I1e183e174cc99dc9e309cc53fbde9f545eb8536f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3877525
Tested-by: George Burgess <gbiv@chromium.org>
Commit-Queue: George Burgess <gbiv@chromium.org>
Reviewed-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
-rwxr-xr-x | toolchain_utils_githooks/check-presubmit.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/toolchain_utils_githooks/check-presubmit.py b/toolchain_utils_githooks/check-presubmit.py index f9da974b..691e2510 100755 --- a/toolchain_utils_githooks/check-presubmit.py +++ b/toolchain_utils_githooks/check-presubmit.py @@ -12,6 +12,7 @@ import datetime import multiprocessing import multiprocessing.pool import os +from pathlib import Path import re import shlex import shutil @@ -20,25 +21,24 @@ import sys import threading import traceback import typing as t -from pathlib import Path def run_command_unchecked( command: t.List[str], cwd: str, env: t.Dict[str, str] = None ) -> t.Tuple[int, str]: """Runs a command in the given dir, returning its exit code and stdio.""" - p = subprocess.Popen( + p = subprocess.run( command, + check=False, cwd=cwd, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env, + encoding="utf-8", + errors="replace", ) - - stdout, _ = p.communicate() - exit_code = p.wait() - return exit_code, stdout.decode("utf-8", "replace") + return p.returncode, p.stdout def has_executable_on_path(exe: str) -> bool: |