fix query_result path logic

This commit is contained in:
Patrick Jentsch 2021-02-01 13:50:07 +01:00
parent ab9e5347be
commit 49e4c837d6

View File

@ -336,7 +336,7 @@ def add_query_result():
db.session.flush()
db.session.refresh(query_result)
try:
os.makedirs(query_result.path)
os.makedirs(os.path.dirname(query_result.path))
except OSError:
logging.error('Make dir {} led to an OSError!'.format(query_result.path)) # noqa
db.session.rollback()
@ -344,11 +344,9 @@ def add_query_result():
return make_response(
{'redirect_url': url_for('.add_query_result')}, 500)
# save the uploaded file
query_result_file_path = os.path.join(query_result.path,
query_result.filename)
form.file.data.save(query_result_file_path)
form.file.data.save(query_result.path)
# parse json from file
with open(query_result_file_path, 'r') as file:
with open(query_result.path, 'r') as file:
query_result_file_content = json.load(file)
# parse json schema
with open('app/static/json_schema/nopaque_cqi_py_results_schema.json', 'r') as file: # noqa