tox plugin that makes tox use `pyenv which` to find python executables
Overall
score
98%
Build a simple process execution wrapper that uses a custom exception hierarchy to handle different types of process execution failures.
Your task is to implement a process runner module that executes system commands and handles errors using a well-structured exception hierarchy.
Design and implement a custom exception hierarchy with:
The hierarchy should follow Python exception best practices where more specific exceptions inherit from more general ones.
Implement a function that executes system commands with the following behavior:
@generates
class ProcessException(Exception):
"""Base exception for process execution errors."""
pass
class ExecutableNotFound(ProcessException):
"""Raised when the requested executable cannot be found."""
pass
class ExecutionFailed(ProcessException):
"""Raised when the executable runs but exits with non-zero status."""
pass
def run_command(executable, *args):
"""
Execute a system command and return its output.
Args:
executable: The command/executable name to run
*args: Optional arguments to pass to the command
Returns:
str: The stdout output from the command (stripped)
Raises:
ExecutableNotFound: If the executable cannot be found
ExecutionFailed: If the executable exits with non-zero status
"""
passThis implementation should use only Python standard library modules.
Install with Tessl CLI
npx tessl i tessl/pypi-tox-pyenvdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10