<s> import json <EOL> import sys <EOL> from boto . s3 . connection import S3Connection <EOL> from boto . s3 . key import Key <EOL> import config <EOL> import utils <EOL> if len ( sys . argv ) < <NUM_LIT:2> : <EOL> sys . exit ( '<STR_LIT>' ) <EOL> ENVIRONMENT = sys . argv [ <NUM_LIT:1> ] <EOL> collection = utils . get_label_collection ( ) <EOL> row_count = <NUM_LIT:0> <EOL> deployed = <NUM_LIT:0> <EOL> c = S3Connection ( ) <EOL> bucket = c . get_bucket ( config . S3_BUCKETS [ ENVIRONMENT ] ) <EOL> for dataset in collection . find ( ) : <EOL> row_count += <NUM_LIT:1> <EOL> del dataset [ '<STR_LIT>' ] <EOL> print dataset [ '<STR_LIT>' ] <EOL> k = Key ( bucket ) <EOL> k . key = '<STR_LIT>' % dataset [ '<STR_LIT>' ] <EOL> jsonp = '<STR_LIT>' % ( dataset [ '<STR_LIT>' ] , json . dumps ( dataset ) ) <EOL> compressed = utils . gzip_data ( jsonp ) <EOL> k . set_contents_from_string ( compressed , headers = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } , policy = '<STR_LIT>' ) <EOL> deployed += <NUM_LIT:1> <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' % row_count <EOL> print '<STR_LIT>' % deployed </s>
