Skip to content

Commit

Permalink
fix: Handle command execution failures
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed May 10, 2021
1 parent 0c21718 commit dcdb15d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions bench/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# imports - compatibility imports
from __future__ import print_function

# imports - standard imports
import json
from json.decoder import JSONDecodeError
Expand Down Expand Up @@ -237,10 +234,16 @@ def validate_app_installed_on_sites(app, bench_path="."):


def check_app_installed(app, bench_path="."):
out = subprocess.check_output(["bench", "--site", "all", "list-apps", "--format", "json"], cwd=bench_path).decode('utf-8')
try:
out = subprocess.check_output(
["bench", "--site", "all", "list-apps", "--format", "json"],
stderr=open(os.devnull, "wb"),
cwd=bench_path,
).decode('utf-8')
except subprocess.CalledProcessError:
return None

try:
import json
apps_sites_dict = json.loads(out)
except JSONDecodeError:
return None
Expand Down

0 comments on commit dcdb15d

Please sign in to comment.