Python boto3 模块,set_stream_logger() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用boto3.set_stream_logger()

项目:bubuku    作者:zalando-nakadi    | 项目源码 | 文件源码
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
项目:cloudbridge    作者:ms-azure-cloudbroker    | 项目源码 | 文件源码
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
项目:bksync    作者:oddy    | 项目源码 | 文件源码
def TestMain(cfg):
    # boto3.set_stream_logger(name='botocore')
    # os.environ["HTTP_PROXY"] = "http://localhost:8080"    
    # os.environ["HTTPS_PROXY"] = "https://localhost:8999"

    sess = boto3.session.Session( 
            aws_access_key_id       = cfg['access_key_id'],
            aws_secret_access_key   = cfg['access_key'],
            region_name             = cfg['region']
        )

    s3 = sess.resource('s3')

    print '\n--- List Buckets ---'

    for bucket in s3.buckets.all():
        print bucket.name

    bkt = s3.Bucket('fred4')

    # print '\n--- Key exists ---'
    # print bkt.get_key('zuxisaki')     # i dont think this works

    print '\n--- List objects in bucket fred4 ---'

    # len(list(bkt.objects.filter(Prefix='index')))     # One request, doesnt return tons of data!
    for i,obj in enumerate(bkt.objects.all()):          # 1348 items - 2 requests, and boto does it for me. 
        print i, obj.key, obj.size                      # does not fetch the actual object, score
        if i > 10000:  break

    print '\n--- Body reads ---'

    print obj.get()['Body'].read()                          # from iteration
    print bkt.Object('zuxisaki').get()['Body'].read()       # by name

    print '\n--- Body write ---'

    data = 'A'*128
    nm = RandChars(8)
    bkt.Object(nm).put(Body=data)
    print 'Wrote key=',nm

# Is Best rand chars