From 16ba1aacce4736476cd578770e7dbca3e0a37776 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 4 Aug 2019 12:37:50 +0100 Subject: [PATCH] ci: log failed command line, and try enabling stdout line buffering --- .ci/ci_lib.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.ci/ci_lib.py b/.ci/ci_lib.py index e1cb84d5..5a03b906 100644 --- a/.ci/ci_lib.py +++ b/.ci/ci_lib.py @@ -57,8 +57,10 @@ def have_docker(): # ----------------- -# Force stdout FD 1 to be a pipe, so tools like pip don't spam progress bars. +# Force line buffering on stdout. +sys.stdout = os.fdopen(1, 'w', 1) +# Force stdout FD 1 to be a pipe, so tools like pip don't spam progress bars. if 'TRAVIS_HOME' in os.environ: proc = subprocess.Popen( args=['stdbuf', '-oL', 'cat'], @@ -86,8 +88,13 @@ def _argv(s, *args): def run(s, *args, **kwargs): argv = ['/usr/bin/time', '--'] + _argv(s, *args) print('Running: %s' % (argv,)) - ret = subprocess.check_call(argv, **kwargs) - print('Finished running: %s' % (argv,)) + try: + ret = subprocess.check_call(argv, **kwargs) + print('Finished running: %s' % (argv,)) + except Exception: + print('Exception occurred while running: %s' % (argv,)) + raise + return ret