Exemplo n.º 1
0
 def __init__(self):
     self.app = None
     self.response = ServerResponse("HivePubSub")
Exemplo n.º 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()
Exemplo n.º 3
0
 def __init__(self):
     self.app = None
     self.response = ServerResponse("HiveManage")
 def __init__(self):
     self.app = None
     self.response = ServerResponse("HiveInternal")
     self.backup_ftp = None
Exemplo n.º 5
0
 def __init__(self):
     self.app = None
     self.response = ServerResponse("HiveSync")
 def __init__(self, app=None):
     self.app = app
     self.response = ServerResponse("HiveFile")
Exemplo n.º 7
0
 def __init__(self):
     self.app = None
     self.response = ServerResponse("HivePayment")
Exemplo n.º 8
0
 def __init__(self, app=None):
     self.app = app
     self.response = ServerResponse("HiveFile")
     self.ipfs_files = IpfsFiles()
Exemplo n.º 9
0
 def __init__(self, app=None):
     self.app = app
     self.response = ServerResponse("HiveMongoDb")
Exemplo n.º 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()}")
Exemplo n.º 11
0
 def __init__(self, app=None):
     self.app = app
     self.response = ServerResponse("HiveScripting")