This commit is contained in:
parent
d3a8057820
commit
9a7258cb4d
@ -9,6 +9,7 @@ from db import db
|
||||
from models import SampleMetadata
|
||||
from schemas import SampleSchema, SampleMetadataSchema
|
||||
from config import *
|
||||
from app import app
|
||||
from fpika import fpika
|
||||
|
||||
"""
|
||||
@ -20,8 +21,6 @@ __copyright__ = "Copyright 2020, Birbnetes Team"
|
||||
__module_name__ = "endpoints"
|
||||
__version__text__ = "1"
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SampleResource(Resource):
|
||||
"""
|
||||
@ -48,14 +47,14 @@ class SampleResource(Resource):
|
||||
description = request.form.get("description")
|
||||
|
||||
if soundfile.content_type != 'audio/wave':
|
||||
LOGGER.info(
|
||||
app.logger.info(
|
||||
f"Input file was not WAV.")
|
||||
return {'err_msg': 'Input file not a wave file.'}, 415
|
||||
|
||||
try:
|
||||
desc = self.sampleschema.loads(description)
|
||||
except Exception as e:
|
||||
LOGGER.exception(e)
|
||||
app.logger.exception(e)
|
||||
return {'err_msg': 'Input JSON schema invalid'}, 417
|
||||
|
||||
xeger = Xeger(limit=30)
|
||||
@ -81,7 +80,7 @@ class SampleResource(Resource):
|
||||
body=json.dumps({'tag': generated_tag}).encode('UTF-8'))
|
||||
fpika.return_channel(ch)
|
||||
except Exception as e:
|
||||
LOGGER.exception(e)
|
||||
app.logger.exception(e)
|
||||
db.session.rollback()
|
||||
return {"err_msg": str(
|
||||
e), "hint": "DB or downstream service error"}, 569
|
||||
|
Loading…
Reference in New Issue
Block a user