Skip to content

Commit 6c61883

Browse files
committed
Also log failed process call in per-build logfiles.
1 parent 0319a1b commit 6c61883

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

build_docs.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,29 @@ def _file_unchanged(old, new):
9191

9292
def shell_out(cmd, shell=False, logfile=None):
9393
logging.debug("Running command %r", cmd)
94+
now = str(datetime.now())
9495
try:
9596
output = subprocess.check_output(cmd, shell=shell,
9697
stdin=subprocess.PIPE,
9798
stderr=subprocess.STDOUT,
9899
universal_newlines=True)
99100
if logfile:
100101
with open(logfile, 'a+') as log:
101-
log.write("#" + str(datetime.now()) + "\n")
102+
log.write("# " + now + "\n")
103+
log.write(f"# Command {cmd!r} ran successfully:")
102104
log.write(output)
103105
log.write("\n\n")
104106
return output
105107
except subprocess.CalledProcessError as e:
106-
logging.debug("Command failed with output %r", e.output)
107-
raise
108+
if logfile:
109+
with open(logfile, 'a+') as log:
110+
log.write("# " + now + "\n")
111+
log.write(f"# Command {cmd!r} failed:")
112+
log.write(output)
113+
log.write("\n\n")
114+
logging.error("Command failed (see %s at %s)", logfile, now)
115+
else:
116+
logging.error("Command failed with output %r", e.output)
108117

109118

110119
def changed_files(directory, other):

0 commit comments

Comments
 (0)