import boto
from datetime import datetime
s3 = boto.connect_s3()
def aws_read_file(bucket_name, file_path):
bucket = s3.get_bucket(bucket_name)
file = bucket.get_key(file_path)
if file is None:
raise Exception('Code 2: File not found.')
return file
def aws_archive_file(bucket_name, file_from_path, file_to_path):
bucket = s3.get_bucket(bucket_name)
file = bucket.get_key(file_path)
if file is None:
raise Exception('Code 2: File not found.')
bucket.copy_key(file_to_path),
bucket_name,
file_from_path)
bucket.delete_key(file_from_path)