print comamnd output in error case
This commit is contained in:
parent
1ab39431a0
commit
f4f94be674
1 changed files with 14 additions and 6 deletions
|
@ -2,15 +2,23 @@
|
|||
|
||||
from os import environ
|
||||
from flask import Flask, request
|
||||
from subprocess import check_output
|
||||
from subprocess import check_output, CalledProcessError
|
||||
import json
|
||||
from sys import stderr
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/<strategy>', methods=['POST'])
|
||||
def build(strategy):
|
||||
return check_output([
|
||||
f"/{environ['STRATEGIES_DIR']}/{strategy}",
|
||||
json.dumps(request.get_json(), sort_keys=True, indent=4),
|
||||
json.dumps(request.args.to_dict()),
|
||||
])
|
||||
try:
|
||||
return check_output([
|
||||
f"{environ['STRATEGIES_DIR']}/{strategy}",
|
||||
json.dumps(request.get_json(), sort_keys=True, indent=4),
|
||||
json.dumps(request.args.to_dict()),
|
||||
])
|
||||
except CalledProcessError as error:
|
||||
print(error.stdout, file=stderr)
|
||||
print(error.stderr, file=stderr)
|
||||
|
||||
raise error
|
||||
|
||||
|
|
Loading…
Reference in a new issue