From 43c4f0d19fc27c65ae51e273e00bec61604328f8 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Wed, 25 Jul 2018 12:46:30 +0200 Subject: [PATCH 1/6] Log more info when a command fails. --- codecov/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov/__init__.py b/codecov/__init__.py index 82e12136..fd59d33e 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`: output=%s, e=%s' % (cmd, str(getattr(e, 'output', '')), str(e))) def remove_non_ascii(data): From beec5bd1b7fd43641afd50f43a63d6b45d5d4138 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Wed, 25 Jul 2018 12:53:49 +0200 Subject: [PATCH 2/6] Also log return code. --- codecov/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codecov/__init__.py b/codecov/__init__.py index fd59d33e..b82ef6ab 100644 --- a/codecov/__init__.py +++ b/codecov/__init__.py @@ -181,7 +181,8 @@ def try_to_run(cmd): try: return check_output(cmd, shell=True) except subprocess.CalledProcessError as e: - write(' Error running `%s`: output=%s, e=%s' % (cmd, str(getattr(e, 'output', '')), str(e))) + write(' Error running `%s`: output=%s, returncode=%s, e=%s' % (cmd, + str(getattr(e, 'output', '')), e.returncode, str(e))) def remove_non_ascii(data): From d26470a1daa14b08dc0a10c15f64a6a94d890cdc Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Wed, 25 Jul 2018 12:57:05 +0200 Subject: [PATCH 3/6] Correctly include process output with the thrown exception. --- codecov/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codecov/__init__.py b/codecov/__init__.py index b82ef6ab..08968d67 100644 --- a/codecov/__init__.py +++ b/codecov/__init__.py @@ -171,7 +171,7 @@ def check_output(cmd, **popen_args): process = Popen(cmd, stdout=PIPE, **popen_args) output, _ = process.communicate() if process.returncode: - raise CalledProcessError(process.returncode, cmd) + raise CalledProcessError(process.returncode, cmd, output) else: assert process.returncode == 0 return output.decode('utf-8') @@ -181,8 +181,8 @@ def try_to_run(cmd): try: return check_output(cmd, shell=True) except subprocess.CalledProcessError as e: - write(' Error running `%s`: output=%s, returncode=%s, e=%s' % (cmd, - str(getattr(e, 'output', '')), e.returncode, str(e))) + write(' Error running `%s`: output=%s, returncode=%s' % (cmd, str(getattr(e, 'output', str(e))), + e.returncode)) def remove_non_ascii(data): From fb63124c3d5a53daebe6342a69185afd5d5a11e4 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Wed, 25 Jul 2018 13:03:56 +0200 Subject: [PATCH 4/6] Include returncode before the output. --- codecov/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codecov/__init__.py b/codecov/__init__.py index 08968d67..4dfa1cd0 100644 --- a/codecov/__init__.py +++ b/codecov/__init__.py @@ -181,8 +181,8 @@ def try_to_run(cmd): try: return check_output(cmd, shell=True) except subprocess.CalledProcessError as e: - write(' Error running `%s`: output=%s, returncode=%s' % (cmd, str(getattr(e, 'output', str(e))), - e.returncode)) + write(' Error running `%s`: returncode=%s, output=%s' % (cmd, e.returncode, + str(getattr(e, 'output', str(e))))) def remove_non_ascii(data): From 60bf5f802f024f09013d7a24014591a13cd9aab2 Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Wed, 9 Sep 2020 16:50:25 -0400 Subject: [PATCH 5/6] Update codecov/__init__.py --- codecov/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov/__init__.py b/codecov/__init__.py index e32c10b5..623db4e4 100644 --- a/codecov/__init__.py +++ b/codecov/__init__.py @@ -221,7 +221,7 @@ def check_output(cmd, **popen_args): def try_to_run(cmd, shell=False, cwd=None): try: - return check_output(cmd, shell=True, cwd=cwd) + return check_output(cmd, shell=shell, cwd=cwd) except Exception as e: write(' Error running `%s`: returncode=%s, output=%s' % (cmd, e.returncode, str(getattr(e, 'output', str(e))))) From 20f316775205bc4352fc256b8a8d5b8019a5b21c Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Wed, 9 Sep 2020 16:55:47 -0400 Subject: [PATCH 6/6] black --- codecov/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/codecov/__init__.py b/codecov/__init__.py index 623db4e4..d3cc9d4f 100644 --- a/codecov/__init__.py +++ b/codecov/__init__.py @@ -223,8 +223,10 @@ def try_to_run(cmd, shell=False, cwd=None): try: return check_output(cmd, shell=shell, cwd=cwd) except Exception as e: - write(' Error running `%s`: returncode=%s, output=%s' % (cmd, e.returncode, - str(getattr(e, 'output', str(e))))) + write( + " Error running `%s`: returncode=%s, output=%s" + % (cmd, e.returncode, str(getattr(e, "output", str(e)))) + ) return None