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
评论列表
文章目录