From 333d6f0a118d38bb0eb670d3d85795769d37d9cc Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Wed, 5 Sep 2018 13:49:30 -0600 Subject: [PATCH 1/2] Flush stdout and stderr after running a command This should help with out-of-order command output. --- doctr/travis.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doctr/travis.py b/doctr/travis.py index 178032dc..c065d2dd 100644 --- a/doctr/travis.py +++ b/doctr/travis.py @@ -148,6 +148,8 @@ def run(args, shell=False, exit=True): sys.stdout.flush() returncode = run_command_hiding_token(args, token, shell=shell) + sys.stdout.flush() + sys.stderr.flush() if exit and returncode != 0: sys.exit(red("%s failed: %s" % (command, returncode))) From ce5baf3cc965bb1403deec29e136878ce848a8dd Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Wed, 5 Sep 2018 17:18:14 -0600 Subject: [PATCH 2/2] Force all print calls to flush on Travis This should take care of all out-of-order output issues. --- doctr/__main__.py | 4 ++++ doctr/travis.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/doctr/__main__.py b/doctr/__main__.py index 86bcbe93..b652dc4b 100644 --- a/doctr/__main__.py +++ b/doctr/__main__.py @@ -45,6 +45,10 @@ from . import __version__ +# Force all prints to flush to keep the output in order on Travis +builtin_print = print +print = lambda *args, **kwargs: builtin_print(*args, **{'flush': True, **kwargs}) + def make_parser_with_config_adder(parser, config): """factory function for a smarter parser: diff --git a/doctr/travis.py b/doctr/travis.py index c065d2dd..4ae15eea 100644 --- a/doctr/travis.py +++ b/doctr/travis.py @@ -18,6 +18,10 @@ from .common import red, blue DOCTR_WORKING_BRANCH = '__doctr_working_branch' +# Force all prints to flush to keep the output in order on Travis +builtin_print = print +print = lambda *args, **kwargs: builtin_print(*args, **{'flush': True, **kwargs}) + def decrypt_file(file, key): """ Decrypts the file ``file``.