From 3113225fa7446e211c518ce74bcb67449c76f239 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 3 Jun 2019 21:37:34 +0100 Subject: [PATCH] Better error message when try_to_run command fails The `CalledProcessError` object should always have a `.output` attribute, although it may be None, so the `getattr()` will never hit the fallback condition. The logical `or` operator should use the fallback if `e.output` is either None or an empty string, because those are both false-y. Any other possible value will be shown. --- codecov/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov/__init__.py b/codecov/__init__.py index 39d9a980..1dfa9ead 100644 --- a/codecov/__init__.py +++ b/codecov/__init__.py @@ -181,7 +181,7 @@ def try_to_run(cmd): try: return check_output(cmd, shell=True) except subprocess.CalledProcessError as e: - write(' Error running `%s`: %s' % (cmd, str(getattr(e, 'output', str(e))))) + write(' Error running `%s`: %s' % (cmd, e.output or str(e))) def remove_non_ascii(data):