Skip to content

Commit 46e796f

Browse files
committed
Print potential errors after running a command only once
`parse_cmd_output` calls `parse_log_for_error` which outputs potential errors by default via `log.info`. The former then outputs those via `log.warning` again. Fix this by passing `stdout=False` to the latter. Also minor rewording and variable renaming.
1 parent a8c0cad commit 46e796f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

easybuild/tools/run.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,15 @@ def parse_cmd_output(cmd, stdouterr, ec, simple, log_all, log_ok, regexp):
626626

627627
# parse the stdout/stderr for errors when strictness dictates this or when regexp is passed in
628628
if use_regexp or regexp:
629-
res = parse_log_for_error(stdouterr, regexp, msg="Command used: %s" % cmd)
630-
if len(res) > 0:
631-
message = "Found %s errors in command output (output: %s)" % (len(res), "\n\t".join([r[0] for r in res]))
629+
res = parse_log_for_error(stdouterr, regexp, stdout=False)
630+
if res:
631+
errors = "\n\t" + "\n\t".join([r[0] for r in res])
632+
error_str = "error" if len(res) == 1 else "errors"
632633
if use_regexp:
633-
raise EasyBuildError(message)
634+
raise EasyBuildError("Found %s %s in output of %s:%s", len(res), error_str, cmd, errors)
634635
else:
635-
_log.warning(message)
636+
_log.warning("Found %s potential %s (some may be harmless) in output of %s:%s",
637+
len(res), error_str, cmd, errors)
636638

637639
if simple:
638640
if ec:

0 commit comments

Comments
 (0)