@@ -0,0 +1,2361 @@
+#!/usr/bin/env python%0Aimport argparse%0A%0Averbose = False%0Alineages = %5B'H3N2', 'H1N1pdm', 'Vic', 'Yam'%5D%0A%0Adef pull_from_dev(lineage, directory = '../auspice/data/', bucket = 'nextflu-dev'):%0A%09%22%22%22Retrieve JSON files from S3 dev bucket%22%22%22%0A%09%22%22%22Boto expects environmental variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY%22%22%22%0A%09directory = directory.rstrip('/')+'/'%0A%0A%09import boto%0A%09conn = boto.connect_s3()%0A%09b = conn.get_bucket(bucket)%0A%09k = boto.s3.key.Key(b)%0A%0A%09print %22Retrieving JSONs for%22, lineage, %22from bucket%22, bucket%0A%09for postfix in %5B'_tree.json', '_sequences.json', '_frequencies.json', '_meta.json'%5D:%0A%09%09json = lineage + postfix%0A%09%09k.key = 'data/'+json%0A%09%09k.get_contents_to_filename(directory+json)%0A%09%09print json,%22retrieved%22%0A%09%0Adef push_to_production(lineage, directory = '../auspice/data/', bucket = 'nextflu'):%0A%09%22%22%22Upload JSON files to S3 production bucket%22%22%22%0A%09%22%22%22Boto expects environmental variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY%22%22%22%0A%09directory = directory.rstrip('/')+'/'%0A%0A%09import boto%0A%09conn = boto.connect_s3()%0A%09b = conn.get_bucket(bucket)%0A%09k = boto.s3.key.Key(b)%0A%0A%09print %22Uploading JSONs for%22, lineage, %22to bucket%22, bucket%0A%09for postfix in %5B'_tree.json', '_sequences.json', '_frequencies.json', '_meta.json'%5D:%0A%09%09json = lineage + postfix%0A%09%09k.key = 'data/'+json%0A%09%09k.set_contents_from_filename(directory+json)%0A%09%09print json,%22uploaded%22%0A%0Aif __name__==%22__main__%22:%0A%09parser = argparse.ArgumentParser(description = %22sync JSONs between local storage, dev server and production server%22)%09%0A%09parser.add_argument('--dev_bucket', type = str, default = %22nextflu-dev%22, help = %22dev bucket for JSON files%22)%0A%09parser.add_argument('--live_bucket', type = str, default = %22nextflu%22, help = %22dev bucket for JSON files%22)%0A%09parser.add_argument('--pull', action = %22store_true%22, default = False, help = %22pull local files from dev%22)%0A%09parser.add_argument('--push', action = %22store_true%22, default = False, help = %22push local files to production%22)%0A%09parser.add_argument('--sync', action = %22store_true%22, default = False, help = %22sync dev to production%22)%09%0A%09params = parser.parse_args()%0A%0A%09for lineage in lineages:%0A%09%09print '%5CnLineage',lineage%0A%09%09if params.pull or params.sync:%0A%09%09%09pull_from_dev(lineage, directory = '../auspice/data/', bucket = params.dev_bucket)%0A%09%09if params.push or params.sync:%0A%09%09%09push_to_production(lineage, directory = '../auspice/data/', bucket = params.live_bucket)%09%09%09%0A

Include production script to sync JSONs between S3 buckets.