- Better error reporting.

- Flask now uses application's logger instead of its own.
- ucloud file scanner refactored.
This commit is contained in:
ahmadbilalkhalid 2019-12-23 12:58:04 +05:00
commit 972bb5a920
14 changed files with 157 additions and 154 deletions

View file

@ -2,12 +2,27 @@ import os
from flask import Flask, request
from flask_restful import Resource, Api
from werkzeug.exceptions import HTTPException
from ucloud.settings import settings
from ucloud.shared import shared
app = Flask(__name__)
api = Api(app)
app.logger.handlers.clear()
@app.errorhandler(Exception)
def handle_exception(e):
app.logger.error(e)
# pass through HTTP errors
if isinstance(e, HTTPException):
return e
# now you're handling non-HTTP exceptions only
return {'message': 'Server Error'}, 500
def get_vm_entry(mac_addr):
return next(filter(lambda vm: mac_addr in list(zip(*vm.network))[1], shared.vm_pool.vms), None)