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


Python exceptions.CredentialRetrievalError方法代碼示例

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


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

示例1: _create_fetcher

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import CredentialRetrievalError [as 別名]
def _create_fetcher(self, full_uri, headers):
        def fetch_creds():
            try:
                response = self._fetcher.retrieve_full_uri(
                    full_uri, headers=headers)
            except MetadataRetrievalError as e:
                logger.debug("Error retrieving container metadata: %s", e,
                             exc_info=True)
                raise CredentialRetrievalError(provider=self.METHOD,
                                               error_msg=str(e))
            return {
                'access_key': response['AccessKeyId'],
                'secret_key': response['SecretAccessKey'],
                'token': response['Token'],
                'expiry_time': response['Expiration'],
            }
        return fetch_creds 
開發者ID:skarlekar,項目名稱:faces,代碼行數:19,代碼來源:credentials.py

示例2: _set_from_data

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import CredentialRetrievalError [as 別名]
def _set_from_data(self, data):
        expected_keys = ['access_key', 'secret_key', 'token', 'expiry_time']
        if not data:
            missing_keys = expected_keys
        else:
            missing_keys = [k for k in expected_keys if k not in data]

        if missing_keys:
            message = "Credential refresh failed, response did not contain: %s"
            raise CredentialRetrievalError(
                provider=self.method,
                error_msg=message % ', '.join(missing_keys),
            )

        self.access_key = data['access_key']
        self.secret_key = data['secret_key']
        self.token = data['token']
        self._expiry_time = parse(data['expiry_time'])
        logger.debug("Retrieved credentials will expire at: %s",
                     self._expiry_time)
        self._normalize() 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:23,代碼來源:credentials.py

示例3: _create_fetcher

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import CredentialRetrievalError [as 別名]
def _create_fetcher(self, full_uri, headers):
        def fetch_creds():
            try:
                response = self._fetcher.retrieve_full_uri(
                    full_uri, headers=headers)
            except MetadataRetrievalError as e:
                logger.debug("Error retrieving container metadata: %s", e,
                             exc_info=True)
                raise CredentialRetrievalError(provider=self.METHOD,
                                               error_msg=str(e))
            return {
                'access_key': response['AccessKeyId'],
                'secret_key': response['SecretAccessKey'],
                'token': response['Token'],
                'expiry_time': response['Expiration'],
            }

        return fetch_creds 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:20,代碼來源:credentials.py

示例4: _retrieve_credentials_using

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import CredentialRetrievalError [as 別名]
def _retrieve_credentials_using(self, credential_process):
        # We're not using shell=True, so we need to pass the
        # command and all arguments as a list.
        process_list = compat_shell_split(credential_process)
        p = self._popen(process_list,
                        stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE)
        stdout, stderr = p.communicate()
        if p.returncode != 0:
            raise CredentialRetrievalError(
                provider=self.METHOD, error_msg=stderr.decode('utf-8'))
        parsed = botocore.compat.json.loads(stdout.decode('utf-8'))
        version = parsed.get('Version', '<Version key not provided>')
        if version != 1:
            raise CredentialRetrievalError(
                provider=self.METHOD,
                error_msg=("Unsupported version '%s' for credential process "
                           "provider, supported versions: 1" % version))
        try:
            return {
                'access_key': parsed['AccessKeyId'],
                'secret_key': parsed['SecretAccessKey'],
                'token': parsed.get('SessionToken'),
                'expiry_time': parsed.get('Expiration'),
            }
        except KeyError as e:
            raise CredentialRetrievalError(
                provider=self.METHOD,
                error_msg="Missing required key in response: %s" % e
            ) 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:32,代碼來源:credentials.py

示例5: _resolve_credentials_from_source

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import CredentialRetrievalError [as 別名]
def _resolve_credentials_from_source(self, credential_source,
                                         profile_name):
        credentials = self._credential_sourcer.source_credentials(
            credential_source)
        if credentials is None:
            raise CredentialRetrievalError(
                provider=credential_source,
                error_msg=(
                    'No credentials found in credential_source referenced '
                    'in profile %s' % profile_name
                )
            )
        return credentials 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:15,代碼來源:credentials.py


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