From b30f113151bf7c094320bd81faace4e6492fe89c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Boro=C5=84ski?= <94375110+kboronski-ant@users.noreply.github.com> Date: Fri, 30 Sep 2022 19:56:41 +0200 Subject: [PATCH] f4pga/flows/common.sub: print stdout on error optionally (#642) --- f4pga/flows/common.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/f4pga/flows/common.py b/f4pga/flows/common.py index 031b034..454d302 100644 --- a/f4pga/flows/common.py +++ b/f4pga/flows/common.py @@ -133,14 +133,17 @@ class SubprocessException(Exception): return_code: int -def sub(*args, env=None, cwd=None): +def sub(*args, env=None, cwd=None, print_stdout_on_fail=False): """ Execute subroutine. """ out = run(args, capture_output=True, env=env, cwd=cwd) if out.returncode != 0: - print(f"[ERROR]: {args[0]} non-zero return code.\n" f"stderr:\n{out.stderr.decode()}\n\n") + print(f"[ERROR]: {args[0]} non-zero return code.\n") + if print_stdout_on_fail: + print(f"stdout:\n{out.stdout.decode()}\n\n") + print(f"stderr:\n{out.stderr.decode()}\n\n") exit(out.returncode) return out.stdout @@ -179,6 +182,7 @@ def vpr(mode: str, vprargs: VprArgs, cwd=None): + vprargs.optional ), cwd=cwd, + print_stdout_on_fail=True, )