From 59fed0c4a62a3fba44eabba65a6bd559e75e7a8d Mon Sep 17 00:00:00 2001 From: David Perl Date: Wed, 13 Dec 2023 15:23:40 +0000 Subject: [PATCH 1/3] #378 Add shell=True to check for program existence --- diff_cover/command_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff_cover/command_runner.py b/diff_cover/command_runner.py index 2bad10c8..0aa19cd3 100644 --- a/diff_cover/command_runner.py +++ b/diff_cover/command_runner.py @@ -51,7 +51,7 @@ def run_command_for_code(command): """ Returns command's exit code. """ - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) process.communicate() return process.returncode From 0410b2be1e977c243acd391450c6d7a05aa03ee0 Mon Sep 17 00:00:00 2001 From: Matt Bachmann Date: Wed, 13 Dec 2023 19:47:16 -0500 Subject: [PATCH 2/3] Update command_runner.py Black is upset, looks like the change is simple enough --- diff_cover/command_runner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/diff_cover/command_runner.py b/diff_cover/command_runner.py index 0aa19cd3..717c51af 100644 --- a/diff_cover/command_runner.py +++ b/diff_cover/command_runner.py @@ -51,7 +51,9 @@ def run_command_for_code(command): """ Returns command's exit code. """ - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + process = subprocess.Popen( + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True + ) process.communicate() return process.returncode From 13ba02b11ddb0ef77d05b165e68fc78b3ac3e158 Mon Sep 17 00:00:00 2001 From: David Perl Date: Thu, 14 Dec 2023 09:38:11 +0000 Subject: [PATCH 3/3] #378 Explicitly check for FileNotFound instead --- diff_cover/command_runner.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/diff_cover/command_runner.py b/diff_cover/command_runner.py index 717c51af..fb1c4910 100644 --- a/diff_cover/command_runner.py +++ b/diff_cover/command_runner.py @@ -51,10 +51,13 @@ def run_command_for_code(command): """ Returns command's exit code. """ - process = subprocess.Popen( - command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True - ) - process.communicate() + try: + process = subprocess.Popen( + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + process.communicate() + except FileNotFoundError: + return 1 return process.returncode