diff options
| author | Jan Tuomi <jan.tuomi@eficode.com> | 2018-12-18 23:43:01 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@eficode.com> | 2018-12-18 23:43:01 +0200 |
| commit | b5a66fad5946934a6f0a5838385a68da90b1f8a7 (patch) | |
| tree | 62d24d8fd4d18b39241a84c94bb5896c41fa6a0c | |
| parent | 3d791a3e45b3d2db94901f871fbf2804c666954d (diff) | |
Add some error checks
| -rw-r--r-- | remote-https-runner/runner.py | 11 |
1 files 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("/") |
