def connect_ia(self): if not Dataset._ia_bucket: ia = boto.connect_ia() try: Dataset._ia_bucket = ia.get_bucket("kasabi") except: Dataset._ia__bucket = ia.create_bucket("kasabi")
# Statics. ELASTICSEARCH_URL = os.environ['ELASTICSEARCH_URL'] S3_BUCKET = os.environ['S3_BUCKET'] S3_BUCKET_DOMAIN = os.environ.get('S3_BUCKET_DOMAIN') CLOUDAMQP_URL = os.environ.get('CLOUDAMQP_URL') REDIS_URL = os.environ.get('OPENREDIS_URL') IA_ACCESS_KEY_ID = os.environ.get('IA_ACCESS_KEY_ID') IA_SECRET_ACCESS_KEY = os.environ.get('IA_SECRET_ACCESS_KEY') IA_BUCKET = os.environ.get('IA_BUCKET') SEARCH_TIMEOUT = 50 # Connection pools. celery = Celery(broker=CLOUDAMQP_URL) es = ElasticSearch(ELASTICSEARCH_URL) bucket = S3Connection().get_bucket(S3_BUCKET) ia = boto.connect_ia(IA_ACCESS_KEY_ID, IA_SECRET_ACCESS_KEY) archive = ia.lookup(IA_BUCKET) cache = Cache() cache.cache = RedisCache() cache.cache._client = redis.from_url(REDIS_URL) class Record(object): def __init__(self): self.uuid = str(uuid4()) self.content_type = 'application/octet-stream' self.epoch = epoch() self.added = epoch() self.filename = None self.ref = None
import os from datetime import date from logbook import debug, info, warn, error import settings import utils import boto import progressbar collection = {'texts' : 'opensource', 'audio' : 'opensource_audio', 'movies' : 'opensource_movies' } conn = boto.connect_ia(settings.archivedotorg_access_key, settings.archivedotorg_secret_key) pbar = None def exists(bucket, key=""): """ Check whether key exists in bucket in archive.org """ try: bucket = conn.get_bucket(bucket) except boto.exception.S3ResponseError, e: if e.error_code == 'NoSuchBucket': return False else: raise e if key:
# Statics. ELASTICSEARCH_URL = os.environ['ELASTICSEARCH_URL'] S3_BUCKET = os.environ['S3_BUCKET'] S3_BUCKET_DOMAIN = os.environ.get('S3_BUCKET_DOMAIN') CLOUDAMQP_URL = os.environ.get('CLOUDAMQP_URL') REDIS_URL = os.environ.get('OPENREDIS_URL') IA_ACCESS_KEY_ID = os.environ.get('IA_ACCESS_KEY_ID') IA_SECRET_ACCESS_KEY = os.environ.get('IA_SECRET_ACCESS_KEY') IA_BUCKET = os.environ.get('IA_BUCKET') SEARCH_TIMEOUT = 50 # Connection pools. celery = Celery(broker=CLOUDAMQP_URL) es = ElasticSearch(ELASTICSEARCH_URL) bucket = S3Connection().get_bucket(S3_BUCKET) ia = boto.connect_ia(IA_ACCESS_KEY_ID, IA_SECRET_ACCESS_KEY) archive = ia.lookup(IA_BUCKET) cache = Cache() cache.cache = RedisCache() cache.cache._client = redis.from_url(REDIS_URL) class Record(object): def __init__(self): self.uuid = str(uuid4()) self.content_type = 'application/octet-stream' self.epoch = epoch() self.added = epoch() self.filename = None self.ref = None self.description = None