Commits

Anonymous committed 7a857bb

removing s3 credentials

Comments (0)

Files changed (1)

sfgeek/apps/s3songs/management/commands/get_music_bucket_list.py

-__author__ = 'marc'
-# this breaks print
-#from __future__ import print_function
-import pytz
-from datetime import datetime, timedelta
-from django.core.management.base import BaseCommand, CommandError
-
-from django.conf import settings
-import os
-import sys
-import re
-import json
-import getopt
-__author__ = 'marc'
-import boto
-from garage.logger import logger
-
-from s3songs.lib.data_sources.files import music_json_filename
-
-conn = boto.connect_s3(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY)
-
-class Command(BaseCommand):
-    """
-    pull down bucketlist from s3
-    """
-    args = ''
-    help = ''
-    def handle(self, *args, **options):
-
-        print '----- bucket location -----'
-        bucket = conn.get_bucket(settings.BUCKET_NAME)
-
-        print '----- listing bucket -----'
-        dir_list = bucket.list()
-
-        dictionary = map(lambda x: x.key, dir_list)
-
-        clean_dictionary = []
-        for key in dictionary:
-
-            pattern = '[A-Za-z -\/0-9&()]*\.[Mm][Pp]3'
-            match = re.search(pattern, key)
-            if match:
-                hello_key = bucket.get_key(key)
-                hello_url = hello_key.generate_url(0, query_auth=False, force_http=True)
-
-                newkey = {
-                    'key': re.sub('\.[Mm][Pp]3', '', key.encode('ascii', 'ignore')),
-                    'value': hello_url.replace('.s3.amazonaws.com', ''),
-                }
-                clean_dictionary.append(newkey)
-            else:
-                print 'no match' + key.encode('ascii', 'ignore')
-
-
-        f = open(music_json_filename(), 'w')
-        f.write(json.dumps(clean_dictionary))
-        f.close()
-