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


Python exceptions.UnknownSignatureVersionError方法代码示例

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


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

示例1: _resolve_signature_version

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import UnknownSignatureVersionError [as 别名]
def _resolve_signature_version(self, service_name, resolved):
        configured_version = _get_configured_signature_version(
            service_name, self.client_config, self.scoped_config)
        if configured_version is not None:
            return configured_version

        # Pick a signature version from the endpoint metadata if present.
        if 'signatureVersions' in resolved:
            potential_versions = resolved['signatureVersions']
            if service_name == 's3':
                return 's3v4'
            if 'v4' in potential_versions:
                return 'v4'
            # Now just iterate over the signature versions in order until we
            # find the first one that is known to Botocore.
            for known in potential_versions:
                if known in AUTH_TYPE_MAPS:
                    return known
        raise UnknownSignatureVersionError(
            signature_version=resolved.get('signatureVersions')) 
开发者ID:QData,项目名称:deepWordBug,代码行数:22,代码来源:client.py

示例2: _resolve_signature_version

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import UnknownSignatureVersionError [as 别名]
def _resolve_signature_version(self, service_name, resolved):
        configured_version = _get_configured_signature_version(
            service_name, self.client_config, self.scoped_config)
        if configured_version is not None:
            return configured_version

        # Pick a signature version from the endpoint metadata if present.
        if 'signatureVersions' in resolved:
            potential_versions = resolved['signatureVersions']
            if service_name == 's3':
                return 's3v4'
            if 'v4' in potential_versions:
                return 'v4'
            # Now just iterate over the signature versions in order until we
            # find the first one that is known to Botocore.
            for known in AUTH_TYPE_MAPS:
                if known in potential_versions:
                    return known
        raise UnknownSignatureVersionError(
            signature_version=resolved.get('signatureVersions')) 
开发者ID:VirtueSecurity,项目名称:aws-extender,代码行数:22,代码来源:client.py

示例3: _resolve_signature_version

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import UnknownSignatureVersionError [as 别名]
def _resolve_signature_version(self, service_name, resolved):
        # Client config overrides everything.
        client = self.client_config
        if client and client.signature_version is not None:
            return client.signature_version
        # Scoped config overrides picking from the endpoint metadata.
        scoped = self.scoped_config
        if scoped is not None:
            service_config = scoped.get(service_name)
            if service_config is not None and isinstance(service_config, dict):
                version = service_config.get('signature_version')
                if version:
                    logger.debug(
                        "Switching signature version for service %s "
                        "to version %s based on config file override.",
                        service_name, version)
                    return version
        # Pick a signature version from the endpoint metadata if present.
        if 'signatureVersions' in resolved:
            potential_versions = resolved['signatureVersions']
            if service_name == 's3':
                # We currently prefer s3 over s3v4.
                if 's3' in potential_versions:
                    return 's3'
                elif 's3v4' in potential_versions:
                    return 's3v4'
            if 'v4' in potential_versions:
                return 'v4'
            # Now just iterate over the signature versions in order until we
            # find the first one that is known to Botocore.
            for known in AUTH_TYPE_MAPS:
                if known in potential_versions:
                    return known
        raise UnknownSignatureVersionError(
            signature_version=resolved.get('signatureVersions')) 
开发者ID:skarlekar,项目名称:faces,代码行数:37,代码来源:client.py

示例4: sign

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import UnknownSignatureVersionError [as 别名]
def sign(self, operation_name, request, region_name=None,
             signing_type='standard', expires_in=None):
        """Sign a request before it goes out over the wire.

        :type operation_name: string
        :param operation_name: The name of the current operation, e.g.
                               ``ListBuckets``.
        :type request: AWSRequest
        :param request: The request object to be sent over the wire.

        :type region_name: str
        :param region_name: The region to sign the request for.

        :type signing_type: str
        :param signing_type: The type of signing to perform. This can be one of
            three possible values:

            * 'standard'     - This should be used for most requests.
            * 'presign-url'  - This should be used when pre-signing a request.
            * 'presign-post' - This should be used when pre-signing an S3 post.

        :type expires_in: int
        :param expires_in: The number of seconds the presigned url is valid
            for. This parameter is only valid for signing type 'presign-url'.
        """
        if region_name is None:
            region_name = self._region_name

        signature_version = self._choose_signer(operation_name, signing_type)

        # Allow mutating request before signing
        self._event_emitter.emit(
            'before-sign.{0}.{1}'.format(self._service_name, operation_name),
            request=request, signing_name=self._signing_name,
            region_name=self._region_name,
            signature_version=signature_version, request_signer=self)

        if signature_version != botocore.UNSIGNED:
            kwargs = {
                'signing_name': self._signing_name,
                'region_name': region_name,
                'signature_version': signature_version
            }
            if expires_in is not None:
                kwargs['expires'] = expires_in

            try:
                auth = self.get_auth_instance(**kwargs)
            except UnknownSignatureVersionError as e:
                if signing_type != 'standard':
                    raise UnsupportedSignatureVersionError(
                        signature_version=signature_version)
                else:
                    raise e

            auth.add_auth(request) 
开发者ID:skarlekar,项目名称:faces,代码行数:58,代码来源:signers.py

示例5: get_auth_instance

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import UnknownSignatureVersionError [as 别名]
def get_auth_instance(self, signing_name, region_name,
                          signature_version=None, **kwargs):
        """
        Get an auth instance which can be used to sign a request
        using the given signature version.

        :type signing_name: string
        :param signing_name: Service signing name. This is usually the
                             same as the service name, but can differ. E.g.
                             ``emr`` vs. ``elasticmapreduce``.

        :type region_name: string
        :param region_name: Name of the service region, e.g. ``us-east-1``

        :type signature_version: string
        :param signature_version: Signature name like ``v4``.

        :rtype: :py:class:`~botocore.auth.BaseSigner`
        :return: Auth instance to sign a request.
        """
        if signature_version is None:
            signature_version = self._signature_version

        cls = botocore.auth.AUTH_TYPE_MAPS.get(signature_version)
        if cls is None:
            raise UnknownSignatureVersionError(
                signature_version=signature_version)
        # If there's no credentials provided (i.e credentials is None),
        # then we'll pass a value of "None" over to the auth classes,
        # which already handle the cases where no credentials have
        # been provided.
        frozen_credentials = None
        if self._credentials is not None:
            frozen_credentials = self._credentials.get_frozen_credentials()
        kwargs['credentials'] = frozen_credentials
        if cls.REQUIRES_REGION:
            if self._region_name is None:
                raise botocore.exceptions.NoRegionError()
            kwargs['region_name'] = region_name
            kwargs['service_name'] = signing_name
        auth = cls(**kwargs)
        return auth

    # Alias get_auth for backwards compatibility. 
开发者ID:skarlekar,项目名称:faces,代码行数:46,代码来源:signers.py


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