From d6ec6af345711268253dfdcb59116790daec85c6 Mon Sep 17 00:00:00 2001 From: David Perl <115003895+dperl-dls@users.noreply.github.com> Date: Sat, 16 Dec 2023 19:56:45 +0000 Subject: [PATCH] #378 Get a nice error message when running diff-quality with a tool which is not installed (#380) * #378 Add shell=True to check for program existence * Update command_runner.py Black is upset, looks like the change is simple enough * #378 Explicitly check for FileNotFound instead --------- Co-authored-by: Matt Bachmann --- diff_cover/command_runner.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/diff_cover/command_runner.py b/diff_cover/command_runner.py index 2bad10c8..fb1c4910 100644 --- a/diff_cover/command_runner.py +++ b/diff_cover/command_runner.py @@ -51,8 +51,13 @@ def run_command_for_code(command): """ Returns command's exit code. """ - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - process.communicate() + try: + process = subprocess.Popen( + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + process.communicate() + except FileNotFoundError: + return 1 return process.returncode