当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.EndpointConnectionError方法代码示例

本文整理汇总了Python中botocore.exceptions.EndpointConnectionError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.EndpointConnectionError方法的具体用法?Python exceptions.EndpointConnectionError怎么用?Python exceptions.EndpointConnectionError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在botocore.exceptions的用法示例。


在下文中一共展示了exceptions.EndpointConnectionError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _make_api_call

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def _make_api_call(operation_name, **operation_options):
    try:
        result = aws.make_api_call('codebuild', operation_name, **operation_options)
    except ServiceError as ex:
        if ex.code == 'AccessDeniedException':
            io.echo(
                "EB CLI does not have the right permissions to access CodeBuild.\n"
                "To learn more, see Docs: https://docs-aws.amazon.com/codebuild/"
                "latest/userguide/auth-and-access-control-permissions-reference.html"
            )
        raise ex
    except EndpointConnectionError:
        LOG.debug(
            "Caught endpoint timeout for CodeBuild."
            " We are assuming this is because they are not supported in that region yet."
        )
        raise ServiceError("Elastic Beanstalk does not support AWS CodeBuild in this region.")
    return result 
开发者ID:QData,项目名称:deepWordBug,代码行数:20,代码来源:codebuild.py

示例2: find_usage

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def find_usage(self):
        """
        Determine the current usage for each limit of this service,
        and update corresponding Limit via
        :py:meth:`~.AwsLimit._add_current_usage`.
        """
        logger.debug("Getting usage for Lambda metrics")
        try:
            self.connect()
            resp = self.conn.get_account_settings()
        except EndpointConnectionError as ex:
            logger.warn('Skipping Lambda: %s', str(ex))
            return
        self.limits['Function Count']._add_current_usage(
            resp['AccountUsage']['FunctionCount'])
        self.limits['Total Code Size (MiB)']._add_current_usage(
            int((resp['AccountUsage']['TotalCodeSize'])/1048576))
        self._have_usage = True 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:20,代码来源:lambdafunc.py

示例3: find_usage

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def find_usage(self):
        """
        Determine the current usage for each limit of this service,
        and update corresponding Limit via
        :py:meth:`~.AwsLimit._add_current_usage`.
        """
        logger.debug("Checking usage for service %s", self.service_name)
        for lim in self.limits.values():
            lim._reset_usage()
        try:
            self.connect()
            resp = self.conn.get_send_quota()
        except EndpointConnectionError as ex:
            logger.warning('Skipping SES: %s', str(ex))
            return
        except ClientError as ex:
            if ex.response['Error']['Code'] in ['AccessDenied', '503']:
                logger.warning('Skipping SES: %s', ex)
                return
            raise
        self.limits['Daily sending quota']._add_current_usage(
            resp['SentLast24Hours']
        )
        self._have_usage = True
        logger.debug("Done checking usage.") 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:27,代码来源:ses.py

示例4: _update_limits_from_api

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def _update_limits_from_api(self):
        """
        Call the service's API action to retrieve limit/quota information, and
        update AwsLimit objects in ``self.limits`` with this information.
        """
        try:
            self.connect()
            resp = self.conn.get_send_quota()
        except EndpointConnectionError as ex:
            logger.warning('Skipping SES: %s', str(ex))
            return
        except ClientError as ex:
            if ex.response['Error']['Code'] in ['AccessDenied', '503']:
                logger.warning('Skipping SES: %s', ex)
                return
            raise
        self.limits['Daily sending quota']._set_api_limit(resp['Max24HourSend']) 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:19,代码来源:ses.py

示例5: find_usage

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def find_usage(self):
        """
        Determine the current usage for each limit of this service,
        and update corresponding Limit via
        :py:meth:`~.AwsLimit._add_current_usage`.
        """
        logger.debug("Checking usage for service %s", self.service_name)
        self.connect()
        for lim in self.limits.values():
            lim._reset_usage()
        try:
            self._find_delivery_streams()
        except EndpointConnectionError as ex:
            logger.warning(
                'Caught exception when trying to use Firehose ('
                'perhaps the Firehose service is not available in this '
                'region?): %s', ex
            )

        self._have_usage = True
        logger.debug("Done checking usage.") 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:23,代码来源:firehose.py

示例6: test_update_limits_from_api_invalid_region

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def test_update_limits_from_api_invalid_region(self):
        def se_get():
            raise EndpointConnectionError(endpoint_url='myurl')

        mock_conn = Mock()
        mock_conn.get_send_quota.side_effect = se_get

        with patch('%s.connect' % pb) as mock_connect:
            with patch('%s.logger' % pbm) as mock_logger:
                cls = _SesService(21, 43, {}, None)
                cls.conn = mock_conn
                cls._update_limits_from_api()
        assert mock_connect.mock_calls == [call()]
        assert mock_conn.mock_calls == [call.get_send_quota()]
        assert mock_logger.mock_calls == [
            call.warning(
                'Skipping SES: %s',
                'Could not connect to the endpoint URL: "myurl"'
            )
        ]
        assert cls.limits['Daily sending quota'].api_limit is None 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:23,代码来源:test_ses.py

示例7: test_find_usage_connection_fail

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def test_find_usage_connection_fail(self):
        def conn_err():
            raise EndpointConnectionError(endpoint_url='myurl')

        mock_conn = Mock()
        mock_conn.get_account_settings.side_effect = conn_err

        with patch('%s.connect' % pb) as mock_connect:
            with patch('%s.logger' % pbm) as mock_logger:
                cls = _LambdaService(21, 43, {}, None)
                cls.conn = mock_conn
                cls.find_usage()

        assert len(cls.limits) == 6
        assert mock_connect.mock_calls == [call()]
        assert mock_conn.mock_calls == [call.get_account_settings()]
        assert mock_logger.mock_calls == [
            call.debug('Getting limits for Lambda'),
            call.debug('Getting usage for Lambda metrics'),
            call.warn('Skipping Lambda: %s',
                      'Could not connect to the endpoint URL: "myurl"')
        ] 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:24,代码来源:test_lambdafunc.py

示例8: _validate_region

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def _validate_region(self, client, doc):
        try:
            response = client.describe_regions(RegionNames=[doc['regionName']])
            endpoint = parse('Regions[0].Endpoint').find(response)
            if endpoint:
                endpoint = endpoint[0].value
            else:
                raise ValidationException('Unable to extract region endpoint.')

            doc['regionHost'] = endpoint
        except ClientError as ce:
            code = parse('Error.Code').find(ce.response)
            if code:
                code = code[0].value
            else:
                raise

            if code == ClientErrorCode.InvalidParameterValue:
                raise ValidationException('Invalid region', 'regionName')
        except EndpointConnectionError as ece:
            raise ValidationException(ece.message) 
开发者ID:Kitware,项目名称:cumulus,代码行数:23,代码来源:aws.py

示例9: _validate_zone

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def _validate_zone(self, client, doc):
        try:
            client = get_ec2_client(doc)
            client.describe_availability_zones(
                ZoneNames=[doc['availabilityZone']])

        except ClientError as ce:
            code = parse('Error.Code').find(ce.response)
            if code:
                code = code[0].value
            else:
                raise

            if code == ClientErrorCode.InvalidParameterValue:
                raise ValidationException(
                    'Invalid zone', 'availabilityZone')
        except EndpointConnectionError as ece:
            raise ValidationException(ece.message) 
开发者ID:Kitware,项目名称:cumulus,代码行数:20,代码来源:aws.py

示例10: async_resend_email_confirm

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def async_resend_email_confirm(self, email):
        """Resend email confirmation."""

        try:
            async with self._request_lock:
                cognito = self._cognito(username=email)
                await self.cloud.run_executor(
                    partial(
                        cognito.client.resend_confirmation_code,
                        Username=email,
                        ClientId=cognito.client_id,
                    )
                )
        except ClientError as err:
            raise _map_aws_exception(err)
        except EndpointConnectionError:
            raise UnknownError() 
开发者ID:NabuCasa,项目名称:hass-nabucasa,代码行数:19,代码来源:auth.py

示例11: async_login

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def async_login(self, email, password):
        """Log user in and fetch certificate."""

        try:
            async with self._request_lock:
                assert not self.cloud.is_logged_in, "Cannot login if already logged in."

                cognito = self._cognito(username=email)
                await self.cloud.run_executor(
                    partial(cognito.authenticate, password=password)
                )
                self.cloud.id_token = cognito.id_token
                self.cloud.access_token = cognito.access_token
                self.cloud.refresh_token = cognito.refresh_token
            await self.cloud.run_executor(self.cloud.write_user_info)

        except ForceChangePasswordException:
            raise PasswordChangeRequired()

        except ClientError as err:
            raise _map_aws_exception(err)

        except EndpointConnectionError:
            raise UnknownError() 
开发者ID:NabuCasa,项目名称:hass-nabucasa,代码行数:26,代码来源:auth.py

示例12: _async_renew_access_token

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def _async_renew_access_token(self):
        """Renew access token internals.

        Does not consume lock.
        """
        cognito = self._authenticated_cognito

        try:
            await self.cloud.run_executor(cognito.renew_access_token)
            self.cloud.id_token = cognito.id_token
            self.cloud.access_token = cognito.access_token
            await self.cloud.run_executor(self.cloud.write_user_info)

        except ClientError as err:
            raise _map_aws_exception(err)

        except EndpointConnectionError:
            raise UnknownError() 
开发者ID:NabuCasa,项目名称:hass-nabucasa,代码行数:20,代码来源:auth.py

示例13: s3errors

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def s3errors(path):
    """Translate S3 errors to FSErrors."""
    try:
        yield
    except ClientError as error:
        _error = error.response.get("Error", {})
        error_code = _error.get("Code", None)
        response_meta = error.response.get("ResponseMetadata", {})
        http_status = response_meta.get("HTTPStatusCode", 200)
        error_msg = _error.get("Message", None)
        if error_code == "NoSuchBucket":
            raise errors.ResourceError(path, exc=error, msg=error_msg)
        if http_status == 404:
            raise errors.ResourceNotFound(path)
        elif http_status == 403:
            raise errors.PermissionDenied(path=path, msg=error_msg)
        else:
            raise errors.OperationFailed(path=path, exc=error)
    except SSLError as error:
        raise errors.OperationFailed(path, exc=error)
    except EndpointConnectionError as error:
        raise errors.RemoteConnectionError(path, exc=error, msg="{}".format(error)) 
开发者ID:PyFilesystem,项目名称:s3fs,代码行数:24,代码来源:_s3fs.py

示例14: poll_status

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def poll_status(session, _id):
    try:
        result = session.get_query_execution(
            QueryExecutionId=_id
        )
    except ClientError as e:
        if e.response['Error']['Code'] == 'InvalidRequestException':
            print("Please check your query_id. Error message:")
        else:
            print("ClientError. Error message:")
        print(e)
        return None
    except EndpointConnectionError as e:
        print('Please check your credentials including aws_region in config.ini file and Internet connection.',
              'Error message:')
        print(e)
        return None

    state = result['QueryExecution']['Status']['State']

    if state in ('SUCCEEDED', 'FAILED', 'CANCELLED'):
        return result
    else:
        print('Waiting for {} query to end'.format(_id))
        raise Exception 
开发者ID:Wikia,项目名称:sroka,代码行数:27,代码来源:athena_api_helpers.py

示例15: __call__

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import EndpointConnectionError [as 别名]
def __call__(self, *args, **kwargs):
        self._tries = 2

        while self._tries > 0:
            try:
                return self.func(*args, **kwargs)
            except ClientError as ex:
                rex = ex.response['Error']['Code']

                if rex == 'OptInRequired':
                    self.log.info('Service not enabled for {} / {}'.format(
                        args[0].account.account_name,
                        self.func.__name__
                    ))
                    break
                else:
                    if not self.__backoff():
                        raise

            except OSError:
                self.log.exception('Retrying after OSError')
                if not self.__backoff():
                    raise

            except EndpointConnectionError as ex:
                self.log.error(ex)
                break 
开发者ID:RiotGames,项目名称:cloud-inquisitor,代码行数:29,代码来源:wrappers.py


注:本文中的botocore.exceptions.EndpointConnectionError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。