controller.py 文件源码

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

项目:boltkit 作者: neo4j-contrib 项目源码 文件源码
def download_s3(self, package):
        """ Download from private s3 distributions.
        """
        package_path = path_join(self.path, package)
        aws_access_key_id = get_env_variable_or_raise_error("AWS_ACCESS_KEY_ID")
        aws_secret_access_key = get_env_variable_or_raise_error("AWS_SECRET_ACCESS_KEY")

        bucket_name = getenv("BUCKET", DIST_HOST)
        # connect to the bucket
        conn = boto.s3.connect_to_region(
            "eu-west-1",
            aws_access_key_id=aws_access_key_id,
            aws_secret_access_key=aws_secret_access_key,
            is_secure=True,
            calling_format=OrdinaryCallingFormat()
        )
        bucket = conn.get_bucket(bucket_name)
        # Get the Key object of the given key, in the bucket
        k = Key(bucket, package)

        # Ensure the destination exist
        try:
            makedirs(self.path)
        except OSError:
            pass
        self.write("Downloading from aws bucket %s... " % bucket_name)

        # Get the contents of the key into a file
        k.get_contents_to_filename(package_path)
        return package_path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号