Fixed circular dependency
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2020-10-02 04:31:20 +02:00
parent 9fb474d3be
commit 202d065116

View File

@ -3,13 +3,12 @@ import logging
import json
from xeger import Xeger
from flask_restful import Resource
from flask import request
from flask import request, current_app
import requests
from db import db
from models import SampleMetadata
from schemas import SampleSchema, SampleMetadataSchema
from config import *
from app import app
from fpika import fpika
"""
@ -47,14 +46,14 @@ class SampleResource(Resource):
description = request.form.get("description")
if soundfile.content_type != 'audio/wave':
app.logger.info(
current_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:
app.logger.exception(e)
current_app.logger.exception(e)
return {'err_msg': 'Input JSON schema invalid'}, 417
xeger = Xeger(limit=30)
@ -83,7 +82,7 @@ class SampleResource(Resource):
body=json.dumps({'tag': generated_tag}).encode('UTF-8'))
fpika.return_channel(ch)
except Exception as e:
app.logger.exception(e)
current_app.logger.exception(e)
db.session.rollback()
return {"err_msg": str(
e), "hint": "DB or downstream service error"}, 569