Python boto3.set_stream_logger() Examples

The following are 5 code examples of boto3.set_stream_logger(). 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 boto3 , or try the search function .
Example #1
Source File: __init__.py    From jupyterlab-s3-browser with Apache License 2.0 7 votes vote down vote up
def get(self, path=""):
        """
        Takes a path and returns lists of files/objects
        and directories/prefixes based on the path.
        """

        boto3.set_stream_logger("boto3.resources", logging.DEBUG)
        boto3.set_stream_logger("botocore", logging.DEBUG)
        try:
            if not self.s3:
                self.s3 = S3Resource(self.config).s3_resource
            result = get_s3_objects_from_path(self.s3, path)
        except S3ResourceNotFoundException as e:
            print(e)
            result = {
                "error": 404,
                "message": "The requested resource could not be found.",
            }
        except Exception as e:
            print(e)
            result = {"error": 500, "message": str(e)}

        self.finish(json.dumps(result)) 
Example #2
Source File: provider.py    From cloudbridge with MIT License 5 votes vote down vote up
def session(self):
        '''Get a low-level session object or create one if needed'''
        if not self._session:
            if self.config.debug_mode:
                boto3.set_stream_logger(level=log.DEBUG)
            self._session = boto3.session.Session(
                region_name=self.region_name, **self.session_cfg)
        return self._session 
Example #3
Source File: __init__.py    From bubuku with MIT License 5 votes vote down vote up
def __init__(self, region, retries=100):
        boto3.set_stream_logger('boto3', logging.INFO)
        self.session = boto3.Session()
        self.region = region
        self.retries = retries
        self._ec2_client = None
        self._ec2_resource = None
        self._cloudwatch_client = None
        self._iam_client = None 
Example #4
Source File: conftest.py    From sagemaker-experiments with Apache License 2.0 5 votes vote down vote up
def experiment_obj(sagemaker_boto_client):
    description = "{}-{}".format("description", str(uuid.uuid4()))
    boto3.set_stream_logger("", logging.INFO)
    experiment_obj = experiment.Experiment.create(
        experiment_name=name(), description=description, sagemaker_boto_client=sagemaker_boto_client
    )
    yield experiment_obj
    time.sleep(0.5)
    experiment_obj.delete() 
Example #5
Source File: cli.py    From cfn-sphere with Apache License 2.0 4 votes vote down vote up
def sync(config, parameter, suffix, debug, confirm, yes):
    confirm = confirm or yes
    if debug:
        LOGGER.setLevel(logging.DEBUG)
        boto3.set_stream_logger(name='boto3', level=logging.DEBUG)
        boto3.set_stream_logger(name='botocore', level=logging.DEBUG)
    else:
        LOGGER.setLevel(logging.INFO)

    if confirm:
        LOGGER.info("This action will modify AWS infrastructure in account: {0}".format(
            get_first_account_alias_or_account_id()))
    else:
        check_update_available()
        click.confirm('This action will modify AWS infrastructure in account: {0}\nAre you sure?'.format(
            get_first_account_alias_or_account_id()), abort=True)

    try:

        config = Config(config_file=config, cli_params=parameter, stack_name_suffix=suffix)
        StackActionHandler(config).create_or_update_stacks()
    except CfnSphereException as e:
        LOGGER.error(e)
        if debug:
            LOGGER.exception(e)
        sys.exit(1)
    except Exception as e:
        LOGGER.error("Failed with unexpected error")
        LOGGER.exception(e)
        LOGGER.info("Please report at https://github.com/cfn-sphere/cfn-sphere/issues!")
        sys.exit(1)