import subprocess from garcon import task from garcon_contrib.aws.utils.garcon_s3 import get_destination_s3key_path @task.decorate(timeout=7200) def upload_to_s3_from_stdin(activity, destination_s3_key, pipe, bucket): """Extract data from mysql to a file. Args: activity (ActivityWorker): The swf activity worker. destination_s3key (str): Full path to the s3 key. S3 key will be named by this no matter what kind of file it is pipe (Popen): Store pipe signal bucket (str): s3 bucket name Return: dict: A dictionary with a Popen object """ destination = get_destination_s3key_path( bucket, destination_s3_key) p4 = subprocess.Popen(['aws', 's3', 'cp', '-', destination], stdin=pipe.stdout) activity.logger.info('Setup of upload_to_s3_from_stdin pipe task done.') return dict(pipe=p4)