From b5a66fad5946934a6f0a5838385a68da90b1f8a7 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 18 Dec 2018 23:43:01 +0200 Subject: Add some error checks --- remote-https-runner/runner.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/remote-https-runner/runner.py b/remote-https-runner/runner.py index 02d0958..54dea4a 100644 --- a/remote-https-runner/runner.py +++ b/remote-https-runner/runner.py @@ -58,8 +58,14 @@ def key(key): logging.info("User runs command:") logging.info(cmd) + success = True start = time.time() - output = subprocess.check_output(cmd, shell=True) + try: + output = subprocess.check_output(cmd, shell=True) + except Exception, e: + success = False + output = str(e) + end = time.time() duration = "{:.2f}".format(end - start) @@ -73,7 +79,8 @@ def key(key): return jsonify({ "command": cmd, "output": str(output), - "duration": duration + "duration": duration, + "success": success }) @app.route("/") -- cgit v1.3