Python botocore.exceptions.HTTPClientError() Examples
The following are 13
code examples of botocore.exceptions.HTTPClientError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
botocore.exceptions
, or try the search function
.
Example #1
Source File: discovery.py From deepWordBug with Apache License 2.0 | 5 votes |
def _refresh_current_endpoints(self, **kwargs): cache_key = self._create_cache_key(**kwargs) try: response = self._describe_endpoints(**kwargs) endpoints = self._parse_endpoints(response) self._cache[cache_key] = endpoints self._failed_attempts.pop(cache_key, None) return endpoints except (ConnectionError, HTTPClientError): self._failed_attempts[cache_key] = self._time() + 60 return None
Example #2
Source File: endpoint.py From deepWordBug with Apache License 2.0 | 5 votes |
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
Example #3
Source File: s3utils.py From S3Scanner with MIT License | 5 votes |
def getBucketSize(bucketName): """ Use awscli to 'ls' the bucket which will give us the total size of the bucket. NOTE: Function assumes the bucket exists and doesn't catch errors if it doesn't. """ s3 = boto3.client('s3') try: if AWS_CREDS_CONFIGURED is False: s3 = boto3.client('s3', config=Config(signature_version=UNSIGNED)) size_bytes = 0 with time_limit(SIZE_CHECK_TIMEOUT): for page in s3.get_paginator("list_objects_v2").paginate(Bucket=bucketName): for item in page['Contents']: size_bytes += item['Size'] return str(size_bytes) + " bytes" except HTTPClientError as e: if "Timed out!" in str(e): return "Unknown Size - timeout" else: raise e except ClientError as e: if e.response['Error']['Code'] == 'AccessDenied': return "AccessDenied" elif e.response['Error']['Code'] == 'AllAccessDisabled': return "AllAccessDisabled" elif e.response['Error']['Code'] == 'NoSuchBucket': return "NoSuchBucket" else: raise e
Example #4
Source File: discovery.py From bash-lambda-layer with MIT License | 5 votes |
def _refresh_current_endpoints(self, **kwargs): cache_key = self._create_cache_key(**kwargs) try: response = self._describe_endpoints(**kwargs) endpoints = self._parse_endpoints(response) self._cache[cache_key] = endpoints self._failed_attempts.pop(cache_key, None) return endpoints except (ConnectionError, HTTPClientError): self._failed_attempts[cache_key] = self._time() + 60 return None
Example #5
Source File: endpoint.py From bash-lambda-layer with MIT License | 5 votes |
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
Example #6
Source File: discovery.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def _refresh_current_endpoints(self, **kwargs): cache_key = self._create_cache_key(**kwargs) try: response = self._describe_endpoints(**kwargs) endpoints = self._parse_endpoints(response) self._cache[cache_key] = endpoints self._failed_attempts.pop(cache_key, None) return endpoints except (ConnectionError, HTTPClientError): self._failed_attempts[cache_key] = self._time() + 60 return None
Example #7
Source File: endpoint.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
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
Example #8
Source File: discovery.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def _refresh_current_endpoints(self, **kwargs): cache_key = self._create_cache_key(**kwargs) try: response = self._describe_endpoints(**kwargs) endpoints = self._parse_endpoints(response) self._cache[cache_key] = endpoints self._failed_attempts.pop(cache_key, None) return endpoints except (ConnectionError, HTTPClientError): self._failed_attempts[cache_key] = self._time() + 60 return None
Example #9
Source File: endpoint.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
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
Example #10
Source File: vault.py From SnowAlert with Apache License 2.0 | 5 votes |
def decrypt_if_encrypted( ct: Optional[str] = None, envar: Optional[str] = None ) -> Optional[str]: if envar: ct = environ.get(envar) if not ct or len(ct) < 205: # 1-byte plaintext has 205-byte ct return ct try: ctBlob = b64decode(ct) except Exception: ctBlob = ct.encode() try: res = None # retry on incomplete response while res is None or 'Plaintext' not in res: n = 10 try: res = kms.decrypt(CiphertextBlob=ctBlob) except HTTPClientError: # An HTTP Client raised and unhandled exception: # [( # 'SSL routines', # 'ssl3_get_record', # 'decryption failed or bad record mac', # )] # fixed by waiting import time time.sleep(0.1) n -= 1 if n == 0: raise return res['Plaintext'].decode() except ClientError: raise except Exception: return ct
Example #11
Source File: discovery.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def _refresh_current_endpoints(self, **kwargs): cache_key = self._create_cache_key(**kwargs) try: response = self._describe_endpoints(**kwargs) endpoints = self._parse_endpoints(response) self._cache[cache_key] = endpoints self._failed_attempts.pop(cache_key, None) return endpoints except (ConnectionError, HTTPClientError): self._failed_attempts[cache_key] = self._time() + 60 return None
Example #12
Source File: endpoint.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
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
Example #13
Source File: test_aws_secretsmanager_caching.py From aws-secretsmanager-caching-python with Apache License 2.0 | 4 votes |
def pre_test_cleanup(self, client): logger.info('Starting cleanup operation of previous test secrets...') old_secrets = [] two_days_ago = datetime.now() - timedelta(days=2) paginator = client.get_paginator('list_secrets') paginator_config = {'PageSize': 10, 'StartingToken': None} iterator = paginator.paginate(PaginationConfig=paginator_config) try: for page in iterator: logger.info('Fetching results from ListSecretValue...') for secret in page['SecretList']: if secret['Name'].startswith(TestAwsSecretsManagerCachingInteg.fixture_prefix) and \ (secret['LastChangedDate'] > two_days_ago) and (secret['LastAccessedDate'] > two_days_ago): old_secrets.append(secret) try: paginator_config['StartingToken'] = page['NextToken'] except KeyError: logger.info('reached end of list') break time.sleep(0.5) except ClientError as e: logger.error("Got ClientError {0} while calling ListSecrets".format(e.response['Error']['Code'])) except HTTPClientError: logger.error("Got HTTPClientError while calling ListSecrets") except NoCredentialsError: logger.fatal("Got NoCredentialsError while calling ListSecrets.") raise if len(old_secrets) == 0: logger.info("No previously configured test secrets found") for secret in old_secrets: logger.info("Scheduling deletion of secret {}".format(secret['Name'])) try: client.delete_secret(SecretId=secret['Name']) except ClientError as e: logger.error("Got ClientError {0} while calling " "DeleteSecret for secret {1}".format(e.response['Error']['Code'], secret['Name'])) except HTTPClientError: logger.error("Got HTTPClientError while calling DeleteSecret for secret {0}".format(secret['Name'])) time.sleep(0.5) yield None