Skip to content

Commit 758440f

Browse files
committed
Cleaner make capture.
1 parent 76bc509 commit 758440f

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

build_docs.py

+21-8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"""
3333

3434
from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED
35+
from datetime import datetime
3536
import logging
3637
import os
3738
import subprocess
@@ -89,13 +90,19 @@ def _file_unchanged(old, new):
8990
return True
9091

9192

92-
def shell_out(cmd, shell=False):
93+
def shell_out(cmd, shell=False, logfile=None):
9394
logging.debug("Running command %r", cmd)
9495
try:
95-
return subprocess.check_output(cmd, shell=shell,
96-
stdin=subprocess.PIPE,
97-
stderr=subprocess.STDOUT,
98-
universal_newlines=True)
96+
output = subprocess.check_output(cmd, shell=shell,
97+
stdin=subprocess.PIPE,
98+
stderr=subprocess.STDOUT,
99+
universal_newlines=True)
100+
if logfile:
101+
with open(logfile, 'a+') as log:
102+
log.write("#" + str(datetime.now()))
103+
log.write(output)
104+
log.write("\n\n")
105+
return output
99106
except subprocess.CalledProcessError as e:
100107
logging.debug("Command failed with output %r", e.output)
101108
raise
@@ -226,9 +233,15 @@ def build_one(version, git_branch, isdev, quick, venv, build_root, www_root,
226233
sphinxbuild = os.path.join(venv, "bin/sphinx-build")
227234
blurb = os.path.join(venv, "bin/blurb")
228235
shell_out(
229-
"make -C %s PYTHON=%s SPHINXBUILD=%s BLURB=%s VENVDIR=%s SPHINXOPTS='%s' %s >> %s 2>&1" %
230-
(os.path.join(checkout, 'Doc'), python, sphinxbuild, blurb, venv, ' '.join(sphinxopts), maketarget,
231-
os.path.join(log_directory, logname)), shell=True)
236+
["make",
237+
"-C", os.path.join(checkout, 'Doc'),
238+
"PYTHON=" + python,
239+
"SPHINXBUILD=" + sphinxbuild,
240+
"BLURB=" + blurb,
241+
"VENVDIR=" + venv,
242+
"SPHINXOPTS=" + ' '.join(sphinxopts),
243+
maketarget],
244+
logfile=os.path.join(log_directory, logname))
232245
shell_out(['chgrp', '-R', group, log_directory])
233246
changed = changed_files(os.path.join(checkout, "Doc/build/html"), target)
234247
logging.info("Copying HTML files to %s", target)

0 commit comments

Comments
 (0)