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
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
def __function(): raise BaseMoError('text')
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())
def thread_function_error(param1, param2, param3): print(param1 + param2 + param3) raise BaseMoError('error')
def __function(param1, param2, param3): print(param1 + param2 + param3) raise BaseMoError('error')
def internal_server_error(e=None): print(e) mo = BaseMoError(LANG.INTERNAL_SERVER_ERROR) return jsonify(mo.get_message()), 500
def unauthorized(): mo = BaseMoError(LANG.UNAUTHORIZED) return jsonify(mo.get_message()), 401