utils_1.py 341 B

123456789
  1. def get_bucket_and_key(name):
  2. """Connect to S3 and grab bucket and key."""
  3. key, secret, host = get_aws_info()
  4. conn = S3Connection(key, secret, host=host)
  5. try:
  6. bucket = conn.get_bucket(name)
  7. except boto.exception.S3ResponseError:
  8. bucket = conn.create_bucket(name)
  9. return bucket, boto.s3.key.Key(bucket)