From dcdb15d471f47ebfb42908d3b19bc2dac9e6d45a Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 10 May 2021 19:10:06 +0530 Subject: [PATCH] fix: Handle command execution failures --- bench/app.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bench/app.py b/bench/app.py index 6886e0a4..d3f9eff6 100755 --- a/bench/app.py +++ b/bench/app.py @@ -1,6 +1,3 @@ -# imports - compatibility imports -from __future__ import print_function - # imports - standard imports import json from json.decoder import JSONDecodeError @@ -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