def __init__(self):
     self.app = None
     self.response = ServerResponse("HivePubSub")
Beispiel #2
0
# -*- coding: utf-8 -*-
"""
Defines all success and error http response code and body.
For new exception, please define here.
"""
import traceback
import logging

from flask import request

from hive.util.server_response import ServerResponse
from src.utils.http_exception import HiveException, InternalServerErrorException

server_response = ServerResponse("CallV2")


def __get_restful_response_wrapper(func, is_download=False, is_code=False):
    def wrapper(*args, **kwargs):
        try:
            logging.getLogger('http response').info(
                f'enter {request.full_path}, {request.method}')
            return HiveException.get_success_response(func(*args, **kwargs),
                                                      is_download=is_download,
                                                      is_code=is_code)
        except HiveException as e:
            return e.get_error_response()
        except Exception as e:
            logging.getLogger('http response').error(
                f'UNEXPECTED: {traceback.format_exc()}')
            return InternalServerErrorException(
                msg=traceback.format_exc()).get_error_response()
 def __init__(self):
     self.app = None
     self.response = ServerResponse("HiveManage")
 def __init__(self):
     self.app = None
     self.response = ServerResponse("HiveInternal")
     self.backup_ftp = None
Beispiel #5
0
 def __init__(self):
     self.app = None
     self.response = ServerResponse("HiveSync")
 def __init__(self, app=None):
     self.app = app
     self.response = ServerResponse("HiveFile")
 def __init__(self):
     self.app = None
     self.response = ServerResponse("HivePayment")
 def __init__(self, app=None):
     self.app = app
     self.response = ServerResponse("HiveFile")
     self.ipfs_files = IpfsFiles()
Beispiel #9
0
 def __init__(self, app=None):
     self.app = app
     self.response = ServerResponse("HiveMongoDb")
Beispiel #10
0
def handle_exception_500(e):
    response = ServerResponse("HiveNode")
    logging.getLogger("Hive exception").exception(
        f"handle_exception_500: {traceback.format_exc()}")
    return response.response_err(
        INTERNAL_SERVER_ERROR, f"Uncaught exception: {traceback.format_exc()}")
Beispiel #11
0
 def __init__(self, app=None):
     self.app = app
     self.response = ServerResponse("HiveScripting")