1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Improve error handling for docs-build test.

This commit is contained in:
Matt Clay 2018-09-21 00:22:18 -07:00
parent 0677dabad4
commit 2148999048

View file

@ -3,21 +3,32 @@
import os
import re
import subprocess
import sys
def main():
base_dir = os.getcwd() + os.sep
base_dir = os.getcwd() + os.path.sep
docs_dir = os.path.abspath('docs/docsite')
cmd = ['make', 'singlehtmldocs']
sphinx = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=docs_dir)
stdout, stderr = sphinx.communicate()
stdout = stdout.decode('utf-8')
stderr = stderr.decode('utf-8')
if sphinx.returncode != 0:
print("Command '%s' failed with status code: %d" % (' '.join(cmd), sphinx.returncode))
print(stdout)
print(stderr)
return
sys.stderr.write("Command '%s' failed with status code: %d\n" % (' '.join(cmd), sphinx.returncode))
if stdout.strip():
sys.stderr.write("--> Standard Output\n")
sys.stderr.write("%s\n" % stdout.strip())
if stderr.strip():
sys.stderr.write("--> Standard Error\n")
sys.stderr.write("%s\n" % stderr.strip())
sys.exit(1)
with open('docs/docsite/rst_warnings', 'r') as warnings_fd:
output = warnings_fd.read().strip()