Skip to content

Commit

Permalink
feat: allow raise option in get_cmd_output
Browse files Browse the repository at this point in the history
reason: if command exits without output, it raises a CalledProcessError
  • Loading branch information
gavindsouza committed Mar 18, 2020
1 parent a6f72c7 commit 6bb30e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bench/patches/v5/fix_user_permissions.py
Expand Up @@ -12,7 +12,7 @@

def is_sudoers_set():
cmd = ["sudo", "-n", "bench"]
return (not subprocess.call(cmd)) or (change_uid_msg in get_cmd_output(cmd))
return (not subprocess.call(cmd)) or (change_uid_msg in get_cmd_output(cmd, _raise=False))


def is_production_set(bench_path):
Expand Down
4 changes: 2 additions & 2 deletions bench/utils.py
Expand Up @@ -510,13 +510,13 @@ def check_git_for_shallow_clone():
return True


def get_cmd_output(cmd, cwd='.'):
def get_cmd_output(cmd, cwd='.', _raise=True):
try:
output = subprocess.check_output(cmd, cwd=cwd, shell=True, stderr=subprocess.PIPE).strip()
except subprocess.CalledProcessError as e:
if e.output:
output = e.output
else:
elif _raise:
raise
return safe_decode(output)

Expand Down

0 comments on commit 6bb30e3

Please sign in to comment.