示例#1
0
文件: aws.py 项目: 18F/autoapi
def fetch_bucket(bucket_name=None, clear_tables=True):
    '''
    Download the CSV files in the given bucket and add their
    data to the database, optionally clearing the relevant
    database tables first.
    '''

    (client, bucket) = _get_bucket(bucket_name)

    if clear_tables:
        utils.clear_tables()

    for key in bucket.objects.all():
        name, ext = os.path.splitext(key.key)
        logger.info('object found in bucket: {}.{}'.format(name, ext))
        if ext.lstrip('.') not in csvkit.convert.SUPPORTED_FORMATS:
            continue
        fetch_key(client, bucket.name, key.key)
示例#2
0
def fetch_bucket(bucket_name=None, clear_tables=True):
    '''
    Download the CSV files in the given bucket and add their
    data to the database, optionally clearing the relevant
    database tables first.
    '''

    (client, bucket) = _get_bucket(bucket_name)

    if clear_tables:
        utils.clear_tables()

    for key in bucket.objects.all():
        name, ext = os.path.splitext(key.key)
        logger.info('object found in bucket: {}.{}'.format(name, ext))
        if ext.lstrip('.') not in csvkit.convert.SUPPORTED_FORMATS:
            continue
        fetch_key(client, bucket.name, key.key)
示例#3
0
文件: aws.py 项目: EricSchles/autoapi
def fetch_bucket(bucket_name=None, clear_tables=True):
    (client, bucket) = cf_bucket()
    if bucket:
        logger.info('Using bound bucket {0}'.format(bucket))
        logger.info('bucket name {0}'.format(bucket.name))
        # aws.subscribe(bucket.name)
    else:
        bucket_name = bucket_name or config.BUCKET_NAME
        logger.info('Importing bucket {0}'.format(bucket_name))
        # aws.subscribe(bucket_name) lacking permissions
        s3 = boto3.resource('s3')
        client = boto3.client('s3')
        bucket = s3.Bucket(bucket_name)

    if clear_tables:
        utils.clear_tables()

    for key in bucket.objects.all():
        name, ext = os.path.splitext(key.key)
        logger.info('object found in bucket: {}.{}'.format(name, ext))
        if ext.lstrip('.') not in csvkit.convert.SUPPORTED_FORMATS:
            continue
        fetch_key(client, bucket.name, key.key)
示例#4
0
def fetch_bucket(bucket_name=None, clear_tables=True):
    (client, bucket) = cf_bucket()
    if bucket:
        logger.info('Using bound bucket {0}'.format(bucket))
        logger.info('bucket name {0}'.format(bucket.name))
        # aws.subscribe(bucket.name)
    else:
        bucket_name = bucket_name or config.BUCKET_NAME
        logger.info('Importing bucket {0}'.format(bucket_name))
        # aws.subscribe(bucket_name) lacking permissions
        s3 = boto3.resource('s3')
        client = boto3.client('s3')
        bucket = s3.Bucket(bucket_name)

    if clear_tables:
        utils.clear_tables()

    for key in bucket.objects.all():
        name, ext = os.path.splitext(key.key)
        logger.info('object found in bucket: {}.{}'.format(name, ext))
        if ext.lstrip('.') not in csvkit.convert.SUPPORTED_FORMATS:
            continue
        fetch_key(client, bucket.name, key.key)
示例#5
0
def clear():
    utils.clear_tables()
示例#6
0
文件: tasks.py 项目: 18F/autoapi
def clear():
    utils.clear_tables()