Private
Server IP : 195.201.23.43  /  Your IP : 3.128.192.189
Web Server : Apache
System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
User : kdecoratie ( 1041)
PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/awscli/customizations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/python3/dist-packages/awscli/customizations/s3errormsg.py
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Give better S3 error messages.
"""


REGION_ERROR_MSG = (
    'You can fix this issue by explicitly providing the correct region '
    'location using the --region argument, the AWS_DEFAULT_REGION '
    'environment variable, or the region variable in the AWS CLI '
    "configuration file.  You can get the bucket's location by "
    'running "aws s3api get-bucket-location --bucket BUCKET".'
)

ENABLE_SIGV4_MSG = (
    ' You can enable AWS Signature Version 4 by running the command: \n'
    'aws configure set s3.signature_version s3v4'
)


def register_s3_error_msg(event_handlers):
    event_handlers.register('after-call.s3', enhance_error_msg)


def enhance_error_msg(parsed, **kwargs):
    if parsed is None or 'Error' not in parsed:
        # There's no error message to enhance so we can continue.
        return
    if _is_sigv4_error_message(parsed):
        message = (
            'You are attempting to operate on a bucket in a region '
            'that requires Signature Version 4.  '
        )
        message += REGION_ERROR_MSG
        parsed['Error']['Message'] = message
    elif _is_permanent_redirect_message(parsed):
        endpoint = parsed['Error']['Endpoint']
        message = parsed['Error']['Message']
        new_message = message[:-1] + ': %s\n' % endpoint
        new_message += REGION_ERROR_MSG
        parsed['Error']['Message'] = new_message
    elif _is_kms_sigv4_error_message(parsed):
        parsed['Error']['Message'] += ENABLE_SIGV4_MSG


def _is_sigv4_error_message(parsed):
    return ('Please use AWS4-HMAC-SHA256' in
            parsed.get('Error', {}).get('Message', ''))


def _is_permanent_redirect_message(parsed):
    return parsed.get('Error', {}).get('Code', '') == 'PermanentRedirect'


def _is_kms_sigv4_error_message(parsed):
    return ('AWS KMS managed keys require AWS Signature Version 4' in
            parsed.get('Error', {}).get('Message', ''))
Private