diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-02-27 18:06:29 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-02-28 14:57:48 +0100 |
commit | 893ed0fbbf1682a416225fccbd35c3db5e034f56 (patch) | |
tree | fb548eac0975ec169fada3c4441607efb588edab | |
parent | 92448715c1245012e45d6e32a8886887b8b3d37f (diff) | |
download | justbuild-893ed0fbbf1682a416225fccbd35c3db5e034f56.tar.gz |
just-lock: Allow stderr capture and reporting when running commands
-rwxr-xr-x | bin/just-lock.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/bin/just-lock.py b/bin/just-lock.py index ae78c756..01fbdd3b 100755 --- a/bin/just-lock.py +++ b/bin/just-lock.py @@ -156,7 +156,8 @@ def run_cmd( cmd: List[str], *, env: Optional[Any] = None, - stdout: Optional[Any] = subprocess.DEVNULL, + stdout: Optional[Any] = subprocess.DEVNULL, # ignore output by default + stderr: Optional[Any] = subprocess.PIPE, # capture errors by default stdin: Optional[Any] = None, input: Optional[bytes] = None, cwd: str, @@ -172,14 +173,16 @@ def run_cmd( cwd=cwd, env=env, stdout=stdout, + stderr=stderr, stdin=stdin, input=input) if result.returncode == 0: return result.stdout, result.returncode # return successful result if fail_context is not None: - fail("%sCommand %s in %s failed after %d attempt%s" % - (fail_context, cmd, cwd, attempts, "" if attempts == 1 else "s")) - return result.stdout, result.returncode # return result of last failure + fail("%sCommand %s in %s failed after %d attempt%s with:\n%s" % + (fail_context, cmd, cwd, attempts, "" if attempts == 1 else "s", + result.stderr)) + return result.stderr, result.returncode # return result of last failure def try_rmtree(tree: str) -> None: |