<s> """<STR_LIT>""" <EOL> from django . conf import settings <EOL> from django . core . management . base import BaseCommand <EOL> import boto <EOL> from boto . s3 . cors import CORSConfiguration <EOL> class Command ( BaseCommand ) : <EOL> help = "<STR_LIT>" <EOL> def handle ( self , * args , ** options ) : <EOL> conn = boto . connect_s3 ( settings . AWS_ACCESS_KEY_ID , settings . AWS_SECRET_ACCESS_KEY ) <EOL> cors_cfg = CORSConfiguration ( ) <EOL> cors_cfg . add_rule ( [ '<STR_LIT:GET>' , '<STR_LIT:POST>' , '<STR_LIT>' ] , '<STR_LIT:*>' , allowed_header = '<STR_LIT:*>' ) <EOL> try : <EOL> b = conn . get_bucket ( settings . AWS_STORAGE_BUCKET_NAME ) <EOL> b . set_acl ( '<STR_LIT>' ) <EOL> b . set_cors ( cors_cfg ) <EOL> except boto . exception . S3ResponseError : <EOL> b = conn . create_bucket ( settings . AWS_STORAGE_BUCKET_NAME ) <EOL> b . set_acl ( '<STR_LIT>' ) <EOL> b . set_cors ( cors_cfg ) </s>
