From 0414ff4cc346eb171d1a0e793af36c3fb4dac33b Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Mon, 7 Sep 2015 16:27:18 +0100 Subject: [PATCH] Output error if command fails --- scripts/gendoc.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/gendoc.py b/scripts/gendoc.py index f8ec6316..e3e8d3d4 100755 --- a/scripts/gendoc.py +++ b/scripts/gendoc.py @@ -32,17 +32,23 @@ def rst2html(i, o): ) def run_through_template(input): - null = open(os.devnull, 'w') - subprocess.check_output( - [ - 'python', 'build.py', - "-i", "matrix_templates", - "-o", "../scripts/tmp", - "../scripts/"+input - ], - stderr=null, - cwd="../templating", - ) + tmpfile = './tmp/output' + try: + with open(tmpfile, 'w') as out: + subprocess.check_output( + [ + 'python', 'build.py', + "-i", "matrix_templates", + "-o", "../scripts/tmp", + "../scripts/"+input + ], + stderr=out, + cwd="../templating", + ) + except subprocess.CalledProcessError as e: + with open(tmpfile, 'r') as f: + print f.read() + raise def prepare_env(): try: