class FeatureProcessError(ServerError): status = ResponseCode.FEATURE_PROCESS_ERROR message = ResponseCode.message(status) log_message = message def __init__(self, message=None): if message: self.message = message super(FeatureProcessError, self).__init__(self.message)
def get(self, request, client_code, proposer_id, *args, **kwargs): data = { 'status': ResponseCode.SUCCESS, 'message': ResponseCode.message(ResponseCode.SUCCESS) } self.client_code = client_code logger.info('Model pre granting, client_code=%s, proposer_id=%s', client_code, proposer_id) try: # check client_code is not valid if not self.verify(): raise UserIdentityError() # 用proposer_id 获取 model = get_pre_grant_model(proposer_id) pre_grant_amount = model.grant() data.update({ 'res_data': { 'result': 1, 'result_message': u'业务处理成功', 'pre_grant_amount': pre_grant_amount } }) except (UserIdentityError, ) as e: logger.error(e.message) data.update({'status': e.status, 'message': e.message}) except Exception, e: logger.error(e) data.update({ 'status': ResponseCode.FAILED, 'message': ResponseCode.message(ResponseCode.FAILED) })
def audit_task(apply_id, base_data, process_apply_id): data = { cons.RESPONSE_REQUEST_STATUS: ResponseCode.FEATURE_SUCCESS, cons.RESPONSE_REQUEST_MESSAGE: ResponseCode.message(ResponseCode.FEATURE_SUCCESS) } try: logger.info( '\n===========Streams in ASYNC mission control center,Collecting feature now==========' ) logger.info("base_data: %s" % base_data) ret_data = mission_control(base_data) data.update({ 'client_code': base_data.get('client_code', None), 'apply_id': apply_id.get('apply_id', None), 'ret_msg': ret_data, 'process_apply_id': process_apply_id }) except ServerError as e: data = { 'apply_id': apply_id.get('apply_id', None), cons.RESPONSE_REQUEST_STATUS: e.status, cons.RESPONSE_REQUEST_MESSAGE: e.message, 'process_apply_id': process_apply_id } except Exception as e: import traceback traceback.print_exc() data = { 'apply_id': apply_id.get('apply_id', None), cons.RESPONSE_REQUEST_STATUS: ResponseCode.FAILED, cons.RESPONSE_REQUEST_MESSAGE: e.message, 'process_apply_id': process_apply_id } finally: callback_url = base_data['callback_url'] headers = {"Content-type": "application/json; charset=utf-8"} logger.info("%s, %s" % (callback_url, data)) post_data = json.dumps(data) response = requests.post(callback_url, headers=headers, data=post_data) logger.info('Results have already arrived, reply %s', response.content)
class ClientCodeMissing(ServerError): status = ResponseCode.MISSING_CLIENT_CODE message = ResponseCode.message(status)
class AsyncCallInterfaceError(ServerError): status = ResponseCode.ASYNC_CALL_INTERFACE_ERROR message = ResponseCode.message(status)
class CommonFeatureConfigError(ServerError): status = ResponseCode.COMMON_FEATURE_CONFIG_ERROR message = ResponseCode.message(status)
class FeatureConfigError(ServerError): status = ResponseCode.WRONG_FEATURE_CONFIG message = ResponseCode.message(status)
class ClientCodeInexistence(ServerError): status = ResponseCode.UNAVAILABLE_CLIENT_CODE message = ResponseCode.message(status)
class HandleInitializeFailed(ServerError): status = ResponseCode.HANDLE_INIT_ERROR message = ResponseCode.message(status)
class JunkmanInitializeFailed(ServerError): status = ResponseCode.JUNKMAN_INIT_ERROR message = ResponseCode.message(status)
class OriginDataGetError(ServerError): status = ResponseCode.ORIGIN_DATA_GET_ERROR message = ResponseCode.message(status)
class OriginDataGetParmsMiss(ServerError): status = ResponseCode.ORIGIN_DATA_GET_PARMS_MISS message = ResponseCode.message(status)
class RequestTypeError(AttributeError): status = ResponseCode.REQUEST_TYPE_ERROR message = ResponseCode.message(status)
class NoPortraitData(ServerError): status = ResponseCode.NO_PORTRAIT_DATA message = ResponseCode.message(status)
class ServerBusy(ServerError): status = ResponseCode.SERVER_BUSY message = ResponseCode.message(status)
class FeatureNameUnfound(ServerError): status = ResponseCode.FEATURE_UNFOUND message = ResponseCode.message(status)
class DataIdentityUnfound(ServerError): status = ResponseCode.DATAIDENTITY_UNFOUND message = ResponseCode.message(status)
class AsyncCallInterfaceTimeout(ServerError): status = ResponseCode.ASYNC_CALL_INTERFACE_TIMEOUT message = ResponseCode.message(status)
class JunkmanWorkError(ServerError): status = ResponseCode.JUNKMAN_WORK_ERROR message = ResponseCode.message(status)
class InterfaceInfoTableConfigError(ServerError): status = ResponseCode.INTERFACE_INFO_TABLE_CONFIG_ERROR message = ResponseCode.message(status)
class HandleWorkError(ServerError): status = ResponseCode.HANDLE_WORK_ERROR message = ResponseCode.message(status)
class MissingManageType(ServerError): status = ResponseCode.MISSING_JUDGE_TYPE message = ResponseCode.message(status)
class FeatureProcessError(ServerError): status = ResponseCode.FEATURE_PROCESS_ERROR message = ResponseCode.message(status)
class JudgeInitializeFailed(ServerError): status = ResponseCode.JUDGE_INIT_ERROR message = ResponseCode.message(status)
class RelevanceFeatureConfigError(ServerError): status = ResponseCode.RELEVANCE_FEATURE_CONFIG_ERROR message = ResponseCode.message(status)
class JudgeWorkError(ServerError): status = ResponseCode.JUDGE_WORK_ERROR message = ResponseCode.message(status)
class ShuntFeatureConfigError(ServerError): status = ResponseCode.SHUNT_FEATURE_CONFIG_ERROR message = ResponseCode.message(status)
class JudgeReturenError(ServerError): status = ResponseCode.JUDGE_RET_ERROR message = ResponseCode.message(status)
class DoingAsyncCallInterface(ServerError): status = ResponseCode.DOING_ASYNC_CALL_INTERFACE message = ResponseCode.message(status) data_identify = ''
class ProposerIdMissing(ServerError): status = ResponseCode.MISSING_PROPOSER_ID message = ResponseCode.message(status)