tools.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:cfdilib 作者: Vauxoo 项目源码 文件源码
def check_s3(self, bucket, element):  # pragma: no cover
        """This method is a helper con `cache_s3`.
        Read method `cache_s3` for more information.

        :param bucket:
        :param element:
        :return:
        """
        session = boto3.Session(profile_name=self.profile_name)
        s3 = session.resource('s3')

        try:
            s3.meta.client.head_bucket(Bucket=bucket)
        except ClientError:
            # If the bucket does not exists then simply use the original
            # I silently fail returning everything as it is in the url
            return False
        try:
            # If the key does not exists do not return False, but try to
            # create a readonly user in order to not have problems into the
            # travis environment.
            s3.Object(bucket, element).load()
        except ClientError:
            return False
        else:
            return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号