Fixed circular dependency
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9fb474d3be
commit
202d065116
@ -3,13 +3,12 @@ import logging
|
|||||||
import json
|
import json
|
||||||
from xeger import Xeger
|
from xeger import Xeger
|
||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
from flask import request
|
from flask import request, current_app
|
||||||
import requests
|
import requests
|
||||||
from db import db
|
from db import db
|
||||||
from models import SampleMetadata
|
from models import SampleMetadata
|
||||||
from schemas import SampleSchema, SampleMetadataSchema
|
from schemas import SampleSchema, SampleMetadataSchema
|
||||||
from config import *
|
from config import *
|
||||||
from app import app
|
|
||||||
from fpika import fpika
|
from fpika import fpika
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -47,14 +46,14 @@ class SampleResource(Resource):
|
|||||||
description = request.form.get("description")
|
description = request.form.get("description")
|
||||||
|
|
||||||
if soundfile.content_type != 'audio/wave':
|
if soundfile.content_type != 'audio/wave':
|
||||||
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
|
||||||
|
|
||||||
try:
|
try:
|
||||||
desc = self.sampleschema.loads(description)
|
desc = self.sampleschema.loads(description)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
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
|
||||||
|
|
||||||
xeger = Xeger(limit=30)
|
xeger = Xeger(limit=30)
|
||||||
@ -83,7 +82,7 @@ class SampleResource(Resource):
|
|||||||
body=json.dumps({'tag': generated_tag}).encode('UTF-8'))
|
body=json.dumps({'tag': generated_tag}).encode('UTF-8'))
|
||||||
fpika.return_channel(ch)
|
fpika.return_channel(ch)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
app.logger.exception(e)
|
current_app.logger.exception(e)
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return {"err_msg": str(
|
return {"err_msg": str(
|
||||||
e), "hint": "DB or downstream service error"}, 569
|
e), "hint": "DB or downstream service error"}, 569
|
||||||
|
Loading…
Reference in New Issue
Block a user