Esempio n. 1
0
def update_downloads():
    require('settings', provided_by=['production', 'staging'])

    with open('data/songs.csv') as f:
        rows = csv.DictReader(f)

        for row in rows:
            if not row['download_url']:
                print 'Missing download url'
                continue

            filename = row['download_url'].split('/')[-1]

            print filename

            download_request = requests.get(row['download_url'], stream=True)

            with open('downloads/%s' % filename, 'w') as f:
                for chunk in download_request.iter_content(chunk_size=1024):
                    if chunk:
                        f.write(chunk)
                        f.flush()

            s3 = boto.connect_s3()

            deploy_file(s3,
                        'downloads/%s' % filename,
                        '%s/downloads/%s' %
                        (app_config.PROJECT_SLUG, filename),
                        headers={
                            'Cache-Control':
                            'max-age=%i' % app_config.ASSETS_MAX_AGE,
                            'Content-Disposition':
                            'attachment; filename="%s"' % filename
                        })
Esempio n. 2
0
def update_downloads():
    require('settings', provided_by=['production', 'staging'])

    with open('data/songs.csv') as f:
        rows = csv.DictReader(f)

        for row in rows:
            if not row['download_url']:
                print 'Missing download url'
                continue

            filename = row['download_url'].split('/')[-1]

            print filename

            download_request = requests.get(row['download_url'], stream=True)

            with open('downloads/%s' % filename, 'w') as f:
                for chunk in download_request.iter_content(chunk_size=1024):
                    if chunk:
                        f.write(chunk)
                        f.flush()

            bucket = utils.get_bucket(app_config.S3_BUCKET)

            deploy_file(
                bucket,
                'downloads/%s' % filename,
                '%s/downloads/%s' % (app_config.PROJECT_SLUG, filename),
                headers={
                    'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE,
                    'Content-Disposition': 'attachment; filename="%s"' % filename
                }
            )
Esempio n. 3
0
def sitemap():
    """
    Render and deploy sitemap.
    """
    require('settings', provided_by=[staging, production])

    app_config.configure_targets(env.get('settings', None))

    with flat_app.app.test_request_context(path='sitemap.xml'):
        print 'Rendering sitemap.xml'

        view = flat_app.__dict__['_sitemap']
        content = view().data

    with open('.sitemap.xml', 'w') as f:
        f.write(content)

    s3 = boto.connect_s3()

    flat.deploy_file(
        s3,
        '.sitemap.xml',
        app_config.PROJECT_SLUG,
        app_config.DEFAULT_MAX_AGE
    )
Esempio n. 4
0
def sitemap():
    """
    Render and deploy sitemap.
    """
    require('settings', provided_by=[staging, production])

    app_config.configure_targets(env.get('settings', None))

    with flat_app.app.test_request_context(path='sitemap.xml'):
        print 'Rendering sitemap.xml'

        view = flat_app.__dict__['_sitemap']
        content = view().data

    with open('.sitemap.xml', 'w') as f:
        f.write(content)

    s3 = boto.connect_s3()

    flat.deploy_file(s3, '.sitemap.xml', app_config.PROJECT_SLUG,
                     app_config.DEFAULT_MAX_AGE)