Example #1
0
def build_response_message(data=None):
    log_mod = sys_conf.get_section_map(SECTION.LOGGING_MODE)
    if int(log_mod[LOGGING_MODE.LOG_FOR_REQUEST_SUCCESS]) == 1:
        message = BaseMoError(LANG.MESSAGE_SUCCESS).get_message()
        sys_conf.logger.debug('response: %s' % data)
        data = data or message
    return data
Example #2
0
 def verify_token(self, jwt_token, typically):
     """
     nếu là module có chức năng au then thì kiem tra trong redis
     nếu là module khác thì gọi moddule authen để verify token
     :param typically:
     :param jwt_token:
     :return: trả về token nếu hợp lệ
     """
     try:
         if typically == TYPICALLY.BEARER or typically == TYPICALLY.DIGEST:
             return jwt_token
         elif typically == TYPICALLY.BASIC:  # and self.module == self.ADMIN:
             return jwt_token
         return None
     except Exception as e:
         print(e)
         BaseMoError(LANG.INTERNAL_SERVER_ERROR).get_message()
         return None
Example #3
0
def __function():
    raise BaseMoError('text')
Example #4
0
 def decorated(*args, **kwargs):
     try:
         return f(*args, **kwargs)
     except BaseMoError as be:
         print(BaseMoError.get_track_back())
         print('error 1 %s' % be.get_message())
Example #5
0
def thread_function_error(param1, param2, param3):
    print(param1 + param2 + param3)
    raise BaseMoError('error')
Example #6
0
def __function(param1, param2, param3):
    print(param1 + param2 + param3)
    raise BaseMoError('error')
Example #7
0
def internal_server_error(e=None):
    print(e)
    mo = BaseMoError(LANG.INTERNAL_SERVER_ERROR)
    return jsonify(mo.get_message()), 500
Example #8
0
def unauthorized():
    mo = BaseMoError(LANG.UNAUTHORIZED)
    return jsonify(mo.get_message()), 401