當前位置: 首頁>>代碼示例>>Python>>正文


Python hooks.first_non_none_response方法代碼示例

本文整理匯總了Python中botocore.hooks.first_non_none_response方法的典型用法代碼示例。如果您正苦於以下問題:Python hooks.first_non_none_response方法的具體用法?Python hooks.first_non_none_response怎麽用?Python hooks.first_non_none_response使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在botocore.hooks的用法示例。


在下文中一共展示了hooks.first_non_none_response方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_client

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def create_client(self, service_name, region_name, is_secure=True,
                            endpoint_url=None, verify=None,
                            credentials=None, scoped_config=None,
                            api_version=None,
                            client_config=None):
        responses = await self._event_emitter.emit(
            'choose-service-name', service_name=service_name)
        service_name = first_non_none_response(responses, default=service_name)
        service_model = self._load_service_model(service_name, api_version)
        cls = await self._create_client_class(service_name, service_model)
        endpoint_bridge = ClientEndpointBridge(
            self._endpoint_resolver, scoped_config, client_config,
            service_signing_name=service_model.metadata.get('signingName'))
        client_args = self._get_client_args(
            service_model, region_name, is_secure, endpoint_url,
            verify, credentials, scoped_config, client_config, endpoint_bridge)
        service_client = cls(**client_args)
        self._register_retries(service_client)
        self._register_s3_events(
            service_client, endpoint_bridge, endpoint_url, client_config,
            scoped_config)
        self._register_endpoint_discovery(
            service_client, endpoint_url, client_config
        )
        return service_client 
開發者ID:aio-libs,項目名稱:aiobotocore,代碼行數:27,代碼來源:client.py

示例2: _emit_api_params

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def _emit_api_params(self, api_params, operation_model, context):
        # Given the API params provided by the user and the operation_model
        # we can serialize the request to a request_dict.
        operation_name = operation_model.name

        # Emit an event that allows users to modify the parameters at the
        # beginning of the method. It allows handlers to modify existing
        # parameters or return a new set of parameters to use.
        service_id = self._service_model.service_id.hyphenize()
        responses = await self.meta.events.emit(
            'provide-client-params.{service_id}.{operation_name}'.format(
                service_id=service_id,
                operation_name=operation_name),
            params=api_params, model=operation_model, context=context)
        api_params = first_non_none_response(responses, default=api_params)

        event_name = (
            'before-parameter-build.{service_id}.{operation_name}')
        await self.meta.events.emit(
            event_name.format(
                service_id=service_id,
                operation_name=operation_name),
            params=api_params, model=operation_model, context=context)
        return api_params 
開發者ID:aio-libs,項目名稱:aiobotocore,代碼行數:26,代碼來源:client.py

示例3: _needs_retry

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def _needs_retry(self, attempts, operation_model, request_dict,
                           response=None, caught_exception=None):
        service_id = operation_model.service_model.service_id.hyphenize()
        event_name = 'needs-retry.%s.%s' % (
            service_id,
            operation_model.name)
        responses = await self._event_emitter.emit(
            event_name, response=response, endpoint=self,
            operation=operation_model, attempts=attempts,
            caught_exception=caught_exception, request_dict=request_dict)
        handler_response = first_non_none_response(responses)
        if handler_response is None:
            return False
        else:
            # Request needs to be retried, and we need to sleep
            # for the specified number of times.
            logger.debug("Response received to retry, sleeping for "
                         "%s seconds", handler_response)
            await asyncio.sleep(handler_response)
            return True 
開發者ID:aio-libs,項目名稱:aiobotocore,代碼行數:22,代碼來源:endpoint.py

示例4: _needs_retry

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def _needs_retry(self, attempts, operation_model, request_dict,
                     response=None, caught_exception=None):
        event_name = 'needs-retry.%s.%s' % (self._endpoint_prefix,
                                            operation_model.name)
        responses = self._event_emitter.emit(
            event_name, response=response, endpoint=self,
            operation=operation_model, attempts=attempts,
            caught_exception=caught_exception, request_dict=request_dict)
        handler_response = first_non_none_response(responses)
        if handler_response is None:
            return False
        else:
            # Request needs to be retried, and we need to sleep
            # for the specified number of times.
            logger.debug("Response received to retry, sleeping for "
                         "%s seconds", handler_response)
            time.sleep(handler_response)
            return True 
開發者ID:skarlekar,項目名稱:faces,代碼行數:20,代碼來源:endpoint.py

示例5: create_client

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def create_client(self, service_name, region_name, is_secure=True,
                      endpoint_url=None, verify=None,
                      credentials=None, scoped_config=None,
                      api_version=None,
                      client_config=None):
        responses = self._event_emitter.emit(
            'choose-service-name', service_name=service_name)
        service_name = first_non_none_response(responses, default=service_name)
        service_model = self._load_service_model(service_name, api_version)
        cls = self._create_client_class(service_name, service_model)
        endpoint_bridge = ClientEndpointBridge(
            self._endpoint_resolver, scoped_config, client_config,
            service_signing_name=service_model.metadata.get('signingName'))
        client_args = self._get_client_args(
            service_model, region_name, is_secure, endpoint_url,
            verify, credentials, scoped_config, client_config, endpoint_bridge)
        service_client = cls(**client_args)
        self._register_retries(service_client)
        self._register_s3_events(
            service_client, endpoint_bridge, endpoint_url, client_config,
            scoped_config)
        self._register_endpoint_discovery(
            service_client, endpoint_url, client_config
        )
        return service_client 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:27,代碼來源:client.py

示例6: _emit_api_params

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def _emit_api_params(self, api_params, operation_model, context):
        # Given the API params provided by the user and the operation_model
        # we can serialize the request to a request_dict.
        operation_name = operation_model.name

        # Emit an event that allows users to modify the parameters at the
        # beginning of the method. It allows handlers to modify existing
        # parameters or return a new set of parameters to use.
        service_id = self._service_model.service_id.hyphenize()
        responses = self.meta.events.emit(
            'provide-client-params.{service_id}.{operation_name}'.format(
                service_id=service_id,
                operation_name=operation_name),
            params=api_params, model=operation_model, context=context)
        api_params = first_non_none_response(responses, default=api_params)

        event_name = (
            'before-parameter-build.{service_id}.{operation_name}')
        self.meta.events.emit(
            event_name.format(
                service_id=service_id,
                operation_name=operation_name),
            params=api_params, model=operation_model, context=context)
        return api_params 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:26,代碼來源:client.py

示例7: _needs_retry

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def _needs_retry(self, attempts, operation_model, request_dict,
                     response=None, caught_exception=None):
        service_id = operation_model.service_model.service_id.hyphenize()
        event_name = 'needs-retry.%s.%s' % (
            service_id,
            operation_model.name)
        responses = self._event_emitter.emit(
            event_name, response=response, endpoint=self,
            operation=operation_model, attempts=attempts,
            caught_exception=caught_exception, request_dict=request_dict)
        handler_response = first_non_none_response(responses)
        if handler_response is None:
            return False
        else:
            # Request needs to be retried, and we need to sleep
            # for the specified number of times.
            logger.debug("Response received to retry, sleeping for "
                         "%s seconds", handler_response)
            time.sleep(handler_response)
            return True 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:22,代碼來源:endpoint.py

示例8: _needs_retry

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def _needs_retry(self, attempts, operation_model, request_dict,
                     response=None, caught_exception=None):
        event_name = 'needs-retry.%s.%s' % (self._endpoint_prefix,
                                            operation_model.name)
        responses = self._event_emitter.emit(
            event_name, response=response, endpoint=self,
            operation=operation_model, attempts=attempts,
            caught_exception=caught_exception, request_dict=request_dict)
        handler_response = first_non_none_response(responses)
        if handler_response is None:
            return False
        else:
            # Request needs to be retried, and we need to sleep
            # for the specified number of times.
            logger.debug("Response received to retry, sleeping for "
                         "%s seconds", handler_response)
            yield from asyncio.sleep(handler_response, loop=self._loop)
            return True 
開發者ID:skylander86,項目名稱:lambda-text-extractor,代碼行數:20,代碼來源:endpoint.py

示例9: _convert_to_request_dict

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def _convert_to_request_dict(self, api_params, operation_model,
                                 context=None):
        # Given the API params provided by the user and the operation_model
        # we can serialize the request to a request_dict.
        operation_name = operation_model.name

        # Emit an event that allows users to modify the parameters at the
        # beginning of the method. It allows handlers to modify existing
        # parameters or return a new set of parameters to use.
        responses = self.meta.events.emit(
            'provide-client-params.{endpoint_prefix}.{operation_name}'.format(
                endpoint_prefix=self._service_model.endpoint_prefix,
                operation_name=operation_name),
            params=api_params, model=operation_model, context=context)
        api_params = first_non_none_response(responses, default=api_params)

        event_name = (
            'before-parameter-build.{endpoint_prefix}.{operation_name}')
        self.meta.events.emit(
            event_name.format(
                endpoint_prefix=self._service_model.endpoint_prefix,
                operation_name=operation_name),
            params=api_params, model=operation_model, context=context)

        request_dict = self._serializer.serialize_to_request(
            api_params, operation_model)
        prepare_request_dict(request_dict, endpoint_url=self._endpoint.host,
                             user_agent=self._client_config.user_agent,
                             context=context)
        return request_dict 
開發者ID:skarlekar,項目名稱:faces,代碼行數:32,代碼來源:client.py

示例10: emit_first_non_none_response

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def emit_first_non_none_response(self, event_name, **kwargs):
        responses = self._events.emit(event_name, **kwargs)
        return first_non_none_response(responses) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:5,代碼來源:session.py

示例11: _do_get_response

# 需要導入模塊: from botocore import hooks [as 別名]
# 或者: from botocore.hooks import first_non_none_response [as 別名]
def _do_get_response(self, request, operation_model):
        try:
            logger.debug("Sending http request: %s", request)
            history_recorder.record('HTTP_REQUEST', {
                'method': request.method,
                'headers': request.headers,
                'streaming': operation_model.has_streaming_input,
                'url': request.url,
                'body': request.body
            })
            service_id = operation_model.service_model.service_id.hyphenize()
            event_name = 'before-send.%s.%s' % (service_id, operation_model.name)
            responses = self._event_emitter.emit(event_name, request=request)
            http_response = first_non_none_response(responses)
            if http_response is None:
                http_response = self._send(request)
        except HTTPClientError as e:
            return (None, e)
        except Exception as e:
            logger.debug("Exception received when sending HTTP request.",
                         exc_info=True)
            return (None, e)
        # This returns the http_response and the parsed_data.
        response_dict = convert_to_response_dict(http_response, operation_model)

        http_response_record_dict = response_dict.copy()
        http_response_record_dict['streaming'] = \
            operation_model.has_streaming_output
        history_recorder.record('HTTP_RESPONSE', http_response_record_dict)

        protocol = operation_model.metadata['protocol']
        parser = self._response_parser_factory.create_parser(protocol)
        parsed_response = parser.parse(
            response_dict, operation_model.output_shape)
        history_recorder.record('PARSED_RESPONSE', parsed_response)
        return (http_response, parsed_response), None 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:38,代碼來源:endpoint.py


注:本文中的botocore.hooks.first_non_none_response方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。