8000 Improve error reporting in the "try_run" function and correctly include original command output in the error message by Kami · Pull Request #153 · codecov/codecov-python · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Improve error reporting in the "try_run" function and correctly include original command output in the error message #153

Merged
merged 7 commits into from
Sep 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into better_error_output
  • Loading branch information
thomasrockhu authored Sep 9, 2020
commit 7887d3c95a10bbf8aa3ec6f2f8ab850b9e2db306
21 changes: 19 additions & 2 deletions codecov/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,27 @@ def check_output(cmd, **popen_args):

def try_to_run(cmd, shell=False, cwd=None):
try:
return check_output(cmd, shell=True)
except subprocess.CalledProcessError as e:
return check_output(cmd, shell=True, cwd=cwd)
except Exception as e:
write(' Error running `%s`: returncode=%s, output=%s' % (cmd, e.returncode,
str(getattr(e, 'output', str(e)))))
return None


def run_python_coverage(args):
"""Run the Python coverage tool

If it's importable in this Python, launch it using 'python -m'.
Otherwise, look it up on PATH like any other command.
"""
try:
import coverage
except ImportError:
# Coverage is not installed on this Python. Hope it's on PATH.
try_to_run(["coverage"] + args, shell=False)
else:
# Coverage is installed on this Python. Run it as a module.
try_to_run([sys.executable, "-m", "coverage"] + args, shell=False)


def remove_non_ascii(data):
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0