This commit is contained in:
parent
f6273afe7b
commit
b47d9df26d
@ -35,27 +35,32 @@ class SampleResource(Resource):
|
|||||||
Post request send to the endpoint
|
Post request send to the endpoint
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
with start_transaction(op="get-file", name="get-file-from-request"):
|
||||||
if 'file' not in request.files:
|
if 'file' not in request.files:
|
||||||
return {"err_msg": "no file found"}, 469
|
return {"err_msg": "no file found"}, 469
|
||||||
else:
|
else:
|
||||||
soundfile = request.files['file']
|
soundfile = request.files['file']
|
||||||
|
|
||||||
|
with start_transaction(op="get-description", name="get-description-from-request"):
|
||||||
if 'description' not in request.form:
|
if 'description' not in request.form:
|
||||||
return {"err_msg": "no description found"}, 470
|
return {"err_msg": "no description found"}, 470
|
||||||
else:
|
else:
|
||||||
description = request.form.get("description")
|
description = request.form.get("description")
|
||||||
|
|
||||||
|
with start_transaction(op="validate-wave", name="validate-wave-type"):
|
||||||
if soundfile.content_type != 'audio/wave':
|
if soundfile.content_type != 'audio/wave':
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
f"Input file was not WAV.")
|
f"Input file was not WAV.")
|
||||||
return {'err_msg': 'Input file not a wave file.'}, 415
|
return {'err_msg': 'Input file not a wave file.'}, 415
|
||||||
|
|
||||||
|
with start_transaction(op="validate-description", name="validate-description-schema"):
|
||||||
try:
|
try:
|
||||||
desc = self.sampleschema.loads(description)
|
desc = self.sampleschema.loads(description)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
current_app.logger.exception(e)
|
current_app.logger.exception(e)
|
||||||
return {'err_msg': 'Input JSON schema invalid'}, 417
|
return {'err_msg': 'Input JSON schema invalid'}, 417
|
||||||
|
|
||||||
|
with start_transaction(op="tag-generate", name="generate-tag"):
|
||||||
xeger = Xeger(limit=30)
|
xeger = Xeger(limit=30)
|
||||||
while True:
|
while True:
|
||||||
generated_tag = xeger.xeger(r'^[a-zA-Z]+[0-9a-zA-Z_]*$')[:32]
|
generated_tag = xeger.xeger(r'^[a-zA-Z]+[0-9a-zA-Z_]*$')[:32]
|
||||||
|
Loading…
Reference in New Issue
Block a user