Skip to content

Commit

Permalink
fix: raise (by default) when exec_cmd fails
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed Nov 17, 2021
1 parent cd1f526 commit 3995b92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bench/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ class BenchNotFoundError(Exception):

class ValidationError(Exception):
pass

class CannotUpdateReleaseBench(ValidationError):
pass
7 changes: 5 additions & 2 deletions bench/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# imports - module imports
from bench import PROJECT_NAME, VERSION

from bench.exceptions import InvalidRemoteException, ValidationError
from bench.exceptions import CommandFailedError, InvalidRemoteException, ValidationError


logger = logging.getLogger(PROJECT_NAME)
Expand Down Expand Up @@ -109,7 +109,7 @@ def pause_exec(seconds=10):
print(" " * 40, end="\r")


def exec_cmd(cmd, cwd=".", env=None):
def exec_cmd(cmd, cwd=".", env=None, _raise=True):
if env:
env.update(os.environ.copy())

Expand All @@ -122,6 +122,9 @@ def exec_cmd(cmd, cwd=".", env=None):
return_code = subprocess.call(cmd, cwd=cwd, universal_newlines=True, env=env)
if return_code:
logger.warning(f"{cmd_log} executed with exit code {return_code}")
if _raise:
raise CommandFailedError
return return_code


def which(executable: str, raise_err: bool = False) -> str:
Expand Down

0 comments on commit 3995b92

Please sign in to comment.