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