diff --git a/doctr/__main__.py b/doctr/__main__.py index 4d9781a9..41f5f9e9 100644 --- a/doctr/__main__.py +++ b/doctr/__main__.py @@ -28,6 +28,7 @@ import subprocess import yaml import json +import shlex from pathlib import Path @@ -40,6 +41,9 @@ get_travis_branch, copy_to_tmp, checkout_deploy_branch) from . import __version__ +def red(text): + return "\033[31m%s\033[0m" % text + def make_parser_with_config_adder(parser, config): """factory function for a smarter parser: @@ -290,6 +294,11 @@ def deploy(args, parser): print("Don't have permission to push. Not trying.") else: print("The docs have not changed. Not updating") + except BaseException as e: + DOCTR_COMMAND = ' '.join(map(shlex.quote, sys.argv)) + print(red("ERROR: The doctr command %r failed: %s" % (DOCTR_COMMAND, e)), + file=sys.stderr) + raise finally: run(['git', 'checkout', current_commit]) # Ignore error, won't do anything if there was nothing to stash