Skip to content

Commit

Permalink
Bachmann1234#378 Add shell=True to check for program existence
Browse files Browse the repository at this point in the history
  • Loading branch information
dperl-dls committed Dec 13, 2023
1 parent c37cdbe commit a0b744a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion diff_cover/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 29 additions & 0 deletions diff_cover/violationsreporters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,32 @@ def installed(self):
Returns: boolean True if installed
"""
return run_command_for_code(self.command_to_check_install) == 0


class JsonBasedDriver(QualityDriver):
def __init__(
self,
name,
supported_extensions,
command,
expression,
command_to_check_install,
flags=0,
exit_codes=None,
):
"""
args:
expression: regex used to parse report, will be fed lines singly
unless flags contain re.MULTILINE
flags: such as re.MULTILINE
See super for other args
command_to_check_install: (list[str]) command to run
to see if the tool is installed
"""

def installed(self):
"""
Method checks if the provided tool is installed.
Returns: boolean True if installed
"""
return run_command_for_code(self.command_to_check_install) == 0

0 comments on commit a0b744a

Please sign in to comment.