2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-12 00:06:36 +00:00

feat: allow raise option in get_cmd_output

reason: if command exits without output, it raises a CalledProcessError
This commit is contained in:
Gavin D'souza 2020-03-18 20:16:41 +05:30
parent a6f72c770f
commit 6bb30e3148
2 changed files with 3 additions and 3 deletions

View File

@ -12,7 +12,7 @@ from bench.utils import exec_cmd, get_bench_name, get_cmd_output
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):

View File

@ -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)