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


Python exceptions.MetadataRetrievalError方法代碼示例

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


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

示例1: _retrieve_credentials

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import MetadataRetrievalError [as 別名]
def _retrieve_credentials(self, full_url, extra_headers=None):
        headers = {'Accept': 'application/json'}
        if extra_headers is not None:
            headers.update(extra_headers)
        attempts = 0
        while True:
            try:
                return await self._get_response(
                    full_url, headers, self.TIMEOUT_SECONDS)
            except MetadataRetrievalError as e:
                logger.debug("Received error when attempting to retrieve "
                             "container metadata: %s", e, exc_info=True)
                await self._sleep(self.SLEEP_TIME)
                attempts += 1
                if attempts >= self.RETRY_ATTEMPTS:
                    raise 
開發者ID:aio-libs,項目名稱:aiobotocore,代碼行數:18,代碼來源:utils.py

示例2: _get_response

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import MetadataRetrievalError [as 別名]
def _get_response(self, full_url, headers, timeout):
        try:
            timeout = aiohttp.ClientTimeout(total=self.TIMEOUT_SECONDS)
            async with self._session(timeout=timeout) as session:
                async with session.get(full_url, headers=headers) as resp:
                    if resp.status != 200:
                        text = await resp.text()
                        raise MetadataRetrievalError(
                            error_msg=(
                                          "Received non 200 response (%d) "
                                          "from ECS metadata: %s"
                                      ) % (resp.status, text))
                    try:
                        return await resp.json()
                    except ValueError:
                        text = await resp.text()
                        error_msg = (
                            "Unable to parse JSON returned from ECS metadata services"
                        )
                        logger.debug('%s:%s', error_msg, text)
                        raise MetadataRetrievalError(error_msg=error_msg)
        except RETRYABLE_HTTP_ERRORS as e:
            error_msg = ("Received error when attempting to retrieve "
                         "ECS metadata: %s" % e)
            raise MetadataRetrievalError(error_msg=error_msg) 
開發者ID:aio-libs,項目名稱:aiobotocore,代碼行數:27,代碼來源:utils.py

示例3: _create_fetcher

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import MetadataRetrievalError [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

示例4: _get_response

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import MetadataRetrievalError [as 別名]
def _get_response(self, full_url, headers, timeout):
        try:
            response = self._session.get(full_url, headers=headers,
                                         timeout=timeout)
            if response.status_code != 200:
                raise MetadataRetrievalError(
                    error_msg="Received non 200 response (%s) from ECS metadata: %s"
                    % (response.status_code, response.text))
            try:
                return json.loads(response.text)
            except ValueError:
                raise MetadataRetrievalError(
                    error_msg=("Unable to parse JSON returned from "
                               "ECS metadata: %s" % response.text))
        except RETRYABLE_HTTP_ERRORS as e:
            error_msg = ("Received error when attempting to retrieve "
                         "ECS metadata: %s" % e)
            raise MetadataRetrievalError(error_msg=error_msg) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:20,代碼來源:utils.py

示例5: _create_fetcher

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import MetadataRetrievalError [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

示例6: _retrieve_credentials

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import MetadataRetrievalError [as 別名]
def _retrieve_credentials(self, full_url, extra_headers=None):
        headers = {'Accept': 'application/json'}
        if extra_headers is not None:
            headers.update(extra_headers)
        attempts = 0
        while True:
            try:
                return self._get_response(full_url, headers, self.TIMEOUT_SECONDS)
            except MetadataRetrievalError as e:
                logger.debug("Received error when attempting to retrieve "
                             "container metadata: %s", e, exc_info=True)
                self._sleep(self.SLEEP_TIME)
                attempts += 1
                if attempts >= self.RETRY_ATTEMPTS:
                    raise 
開發者ID:skarlekar,項目名稱:faces,代碼行數:17,代碼來源:utils.py


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