コード例 #1
0
ファイル: __init__.py プロジェクト: onyxfish/median
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
            utils.confirm(
                colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")
            )

        servers.checkout_latest(remote)

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        },
        ignore=[]
    )
コード例 #2
0
ファイル: __init__.py プロジェクト: vdedyukhin/elections16
def deploy_cards():
    """
    Deploy content cards.
    """
    require('settings', provided_by=[production, staging])
    local('rm -rf .cards_html')
    COPY = copytext.Copy(app_config.COPY_PATH)
    if env.settings == 'production':
        state = COPY['meta']['prod_state']['value']
    elif env.settings == 'staging':
        state = COPY['meta']['stage_state']['value']
    else:
        state = COPY['meta']['dev_state']['value']

    script = COPY[state]

    for row in script:
        render.render_card_route(row['function'], row['params'])

    render.render_current_state()
    render.render_index()

    flat.deploy_folder(
        app_config.S3_BUCKET,
        '.cards_html',
        '',
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        }
    )
コード例 #3
0
def update_price():
    # pull today
    now = datetime.now()
    today = ("%s-%02d-%02d" % (now.year, now.month, now.day))
    quotes = ystockquote.get_historical_prices('SPY', '2015-01-15',
                                               today)  #pull data

    #writing json
    with open('www/live-data/price.json', 'w') as file:
        json.dump(quotes, file)

    #get current price
    current_price = ystockquote.get_price('SPY')
    current_date = now.strftime('%Y-%m-%d')
    current_time = now.strftime('%H:%M:%S')

    current_value = str(current_date) + "," + str(current_time) + "," + str(
        current_price)
    header = "date,time,price"

    with open('www/live-data/current.csv', 'wb') as f:
        fwriter = csv.writer(f, delimiter=" ")
        fwriter.writerow([header])
        fwriter.writerow([current_value])

    if app_config.DEPLOYMENT_TARGET:
        flat.deploy_folder('www/live-data',
                           'live-data',
                           max_age=app_config.DEFAULT_MAX_AGE)
コード例 #4
0
ファイル: __init__.py プロジェクト: isabella232/leadpipes
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    update()
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE},
        ignore=['www/assets/*', 'www/live-data/*'])

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE})

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
コード例 #5
0
ファイル: __init__.py プロジェクト: livlab/anne-lister-books
def deploy(quick=None, remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[random_prod, production, staging])

    if app_config.DEPLOYMENT_TARGET == 'production' or app_config.DEPLOYMENT_TARGET == 'random_prod':
        utils.confirm(
            colored(
                "You are trying to deploy to production this project %s.\nDo you know what you're doing?"
                % app_config.PROJECT_SLUG, "red"))

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production'
                and env.branch != 'stable'):
            utils.confirm(
                colored(
                    "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?"
                    % env.branch, "red"))

        servers.checkout_latest(remote)

        servers.fabcast('text.update')
        servers.fabcast('data.update')
        servers.fabcast('assets.sync')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    if quick != 'quick':
        update()

    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE},
        ignore=['www/assets/*', 'www/live-data/*'])

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE})

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
コード例 #6
0
ファイル: __init__.py プロジェクト: danilito19/dailygraphics
def deploy(slug):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if not slug:
        print 'You must specify a project slug, like this: "deploy:slug"'
        return

    update_copy(slug)
    assets.sync(slug)
    render(slug)

    graphic_root = '%s/%s' % (app_config.GRAPHICS_PATH, slug)
    s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug)
    graphic_assets = '%s/assets' % graphic_root
    s3_assets = '%s/assets' % s3_root

    flat.deploy_folder(
        graphic_root,
        s3_root,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        },
        ignore=['%s/*' % graphic_assets]
    )

    flat.deploy_folder(
        graphic_assets,
        s3_assets,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
        }
    )
コード例 #7
0
ファイル: __init__.py プロジェクト: yutinghCW/dailygraphics
def deploy_single(path):
    """
    Deploy a single project to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])
    slug, abspath = utils.parse_path(path)
    graphic_root = '%s/%s' % (abspath, slug)
    s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug)
    graphic_assets = '%s/assets' % graphic_root
    s3_assets = '%s/assets' % s3_root
    graphic_node_modules = '%s/node_modules' % graphic_root

    graphic_config = load_graphic_config(graphic_root)

    use_assets = getattr(graphic_config, 'USE_ASSETS', True)
    default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE',
                              None) or app_config.DEFAULT_MAX_AGE
    assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE',
                             None) or app_config.ASSETS_MAX_AGE
    update_copy(path)
    if use_assets:
        error = assets.sync(path)
        if error:
            return

    render.render(path)
    flat.deploy_folder(
        graphic_root,
        s3_root,
        headers={'Cache-Control': 'max-age=%i' % default_max_age},
        ignore=[
            '%s/*' % graphic_assets,
            '%s/*' % graphic_node_modules,
            # Ignore files unused on static S3 server
            '*.xls',
            '*.xlsx',
            '*.pyc',
            '*.py',
            '*.less',
            '*.bak',
            '%s/base_template.html' % graphic_root,
            '%s/child_template.html' % graphic_root,
            '%s/README.md' % graphic_root
        ])

    if use_assets:
        flat.deploy_folder(
            graphic_assets,
            s3_assets,
            headers={'Cache-Control': 'max-age=%i' % assets_max_age},
            ignore=['%s/private/*' % graphic_assets])

    # Need to explicitly point to index.html for the AWS staging link
    file_suffix = ''
    if env.settings == 'staging':
        file_suffix = 'index.html'

    print ''
    print '%s URL: %s/graphics/%s/%s' % (
        env.settings.capitalize(), app_config.S3_BASE_URL, slug, file_suffix)
コード例 #8
0
ファイル: __init__.py プロジェクト: nprapps/anno-docs
def deploy_embeds():
    render.render_embeds()
    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/embeds',
        '%s%s/embeds' %
        (app_config.FACTCHECKS_DIRECTORY_PREFIX, app_config.CURRENT_FACTCHECK),
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})
コード例 #9
0
ファイル: __init__.py プロジェクト: mroswell/books15
def deploy(quick=None, remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
            utils.confirm(
                colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")
            )

        servers.checkout_latest(remote)

        servers.fabcast('text.update')
        servers.fabcast('assets.sync')
        servers.fabcast('data.update')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    if quick != 'quick':
        update()

    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        },
        ignore=['www/assets/*', 'www/live-data/*']
    )

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
        }
    )

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
コード例 #10
0
ファイル: __init__.py プロジェクト: wbez/debates
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])
    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production'
                and env.branch != 'stable'):
            utils.confirm(
                colored(
                    "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?"
                    % env.branch, "red"))

        servers.checkout_latest(remote)

        # servers.fabcast('text.update')
        # servers.fabcast('assets.sync')
        # servers.fabcast('data.update')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        '%s%s' %
        (app_config.DEBATE_DIRECTORY_PREFIX, app_config.CURRENT_DEBATE),
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE},
        ignore=['www/assets/*', 'www/live-data/*'])

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s%s/assets' %
        (app_config.DEBATE_DIRECTORY_PREFIX, app_config.CURRENT_DEBATE),
        headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE})

    # DEPLOY STATIC FACTCHECK FROM LOCAL ENVIRONMENT
    if app_config.DEPLOY_STATIC_FACTCHECK:
        execute('deploy_factcheck')

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
コード例 #11
0
def deploy_single(path):
    """
    Deploy a single project to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])
    slug, abspath = utils.parse_path(path)
    graphic_root = '%s/%s' % (abspath, slug)
    s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug)
    graphic_assets = '%s/assets' % graphic_root
    s3_assets = '%s/assets' % s3_root
    graphic_node_modules = '%s/node_modules' % graphic_root

    graphic_config = load_graphic_config(graphic_root)

    use_assets = getattr(graphic_config, 'USE_ASSETS', True)
    default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE
    assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE
    update_copy(path)
    if use_assets:
        error = assets.sync(path)
        if error:
            return

    render.render(path)
    flat.deploy_folder(
        graphic_root,
        s3_root,
        headers={
            'Cache-Control': 'max-age=%i' % default_max_age
        },
        ignore=['%s/*' % graphic_assets, '%s/*' % graphic_node_modules,
                # Ignore files unused on static S3 server
                '*.xls', '*.xlsx', '*.pyc', '*.py', '*.less', '*.bak',
                '%s/base_template.html' % graphic_root,
                '%s/child_template.html' % graphic_root,
                '%s/README.md' % graphic_root]
    )

    if use_assets:
        flat.deploy_folder(
            graphic_assets,
            s3_assets,
            headers={
                'Cache-Control': 'max-age=%i' % assets_max_age
            },
            ignore=['%s/private/*' % graphic_assets]
        )

    # Need to explicitly point to index.html for the AWS staging link
    file_suffix = ''
    if env.settings == 'staging':
        file_suffix = 'index.html'

    print ''
    print '%s URL: %s/graphics/%s/%s' % (env.settings.capitalize(), app_config.S3_BASE_URL, slug, file_suffix)
コード例 #12
0
ファイル: __init__.py プロジェクト: wbez/debates
def deploy_factcheck():
    render.render_factcheck()
    flat.deploy_folder(
        app_config.S3_BUCKET,
        '.factcheck',
        '%s%s' %
        (app_config.DEBATE_DIRECTORY_PREFIX, app_config.CURRENT_DEBATE),
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})

    if app_config.DEPLOYMENT_TARGET == 'production':
        execute('deploy_transcript_backup')
コード例 #13
0
ファイル: __init__.py プロジェクト: wbez/debates
def deploy_transcript_backup():
    """
    deploy to our backup S3 bucket election-backup.apps.npr.org
    """
    now = datetime.now().strftime('%Y-%m-%d-%H:%M:%S')

    flat.deploy_folder(
        app_config.ARCHIVE_S3_BUCKET,
        '.copydoc',
        'debates/%s-%s' % (now, app_config.CURRENT_DEBATE),
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})
コード例 #14
0
ファイル: cron_jobs.py プロジェクト: ebigalee/graeae
def backup():
    """
    Back up the database
    """
    import data
    today = time.strftime('%Y-%m-%d') 
    dst_directory = 'backup/{0}'.format(today)
    dump_directory = '/tmp/graeae-backup/{0}'.format(today)
    data.dump_db(dump_directory)
    flat.deploy_folder(app_config.BACKUP_S3_BUCKET, dump_directory, dst_directory)
    local('rm -Rf /tmp/graeae-backup')
コード例 #15
0
def deploy_test():
    require('settings', provided_by=[production, staging])
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        'www',
        app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE},
        ignore=['www/assets/*'])
コード例 #16
0
ファイル: __init__.py プロジェクト: isabella232/liveblog-1
def deploy_liveblog_backup():
    """
    deploy to our backup S3 bucket election-backup.apps.npr.org
    """
    now = datetime.now().strftime('%Y-%m-%d-%H:%M:%S')

    flat.deploy_folder(
        app_config.ARCHIVE_S3_BUCKET,
        '.liveblog',
        'liveblogs/%s/%s-%s' %
        (app_config.CURRENT_LIVEBLOG, now, app_config.PROJECT_SLUG),
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})
コード例 #17
0
ファイル: cron_jobs.py プロジェクト: isabella232/graeae
def backup():
    """
    Back up the database
    """
    import data
    today = time.strftime('%Y-%m-%d')
    dst_directory = 'backup/{0}'.format(today)
    dump_directory = '/tmp/graeae-backup/{0}'.format(today)
    data.dump_db(dump_directory)
    flat.deploy_folder(app_config.BACKUP_S3_BUCKET, dump_directory,
                       dst_directory)
    local('rm -Rf /tmp/graeae-backup')
コード例 #18
0
ファイル: __init__.py プロジェクト: vdedyukhin/elections16
def deploy_results_data():
    """
    Deploy results cards.
    """
    local('rm -rf .cards_html/data')
    render.render_results_json()
    flat.deploy_folder(
        app_config.S3_BUCKET,
        '.cards_html/data',
        'data',
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        }
    )
コード例 #19
0
def deploy(remote="origin"):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require("settings", provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require("branch", provided_by=[stable, master, branch])

        if app_config.DEPLOYMENT_TARGET == "production" and env.branch != "stable":
            utils.confirm(
                colored(
                    "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?"
                    % env.branch,
                    "red",
                )
            )

        servers.checkout_latest(remote)

        servers.fabcast("text.update")
        servers.fabcast("assets.sync")
        servers.fabcast("data.update")

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()

    # Clear files that should never be deployed
    local("rm -rf www/live-data")

    flat.deploy_folder(
        "www",
        app_config.PROJECT_SLUG,
        headers={"Cache-Control": "max-age=%i" % app_config.DEFAULT_MAX_AGE},
        ignore=["www/assets/*", "www/live-data/*"],
    )

    flat.deploy_folder(
        "www/assets",
        "%s/assets" % app_config.PROJECT_SLUG,
        headers={"Cache-Control": "max-age=%i" % app_config.ASSETS_MAX_AGE},
    )
コード例 #20
0
ファイル: __init__.py プロジェクト: vdedyukhin/elections16
def deploy_delegates_data():
    """
    Deploy results cards.
    """
    require('settings', provided_by=[production, staging])

    local('rm -rf .cards_html/data')
    render.render_delegates_json()
    flat.deploy_folder(
        app_config.S3_BUCKET,
        '.cards_html/data',
        'data',
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        }
    )
コード例 #21
0
ファイル: __init__.py プロジェクト: isabella232/graeae
def deploy(analyse=True, remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production'
                and env.branch != 'stable'):
            utils.confirm(
                colored(
                    "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?"
                    % env.branch, "red"))

        servers.checkout_latest(remote)

        servers.fabcast('text.update')
        servers.fabcast('assets.sync')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    if analyse == True:
        execute('analysis.analyse')
        execute('render.render_all')

        flat.deploy_folder(app_config.S3_BUCKET['bucket_name'],
                           'www',
                           app_config.PROJECT_SLUG,
                           headers={
                               'Cache-Control':
                               'max-age=%i' % app_config.DEFAULT_MAX_AGE
                           },
                           ignore=['www/assets/*'])

        flat.deploy_folder(app_config.S3_BUCKET['bucket_name'],
                           'www/assets',
                           '%s/assets' % app_config.PROJECT_SLUG,
                           headers={
                               'Cache-Control':
                               'max-age=%i' % app_config.ASSETS_MAX_AGE
                           })
コード例 #22
0
def _deploy_to_s3(path='.gzip'):
    """
    Deploy the gzipped stuff to S3.
    """
    # Clear files that should never be deployed
    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE},
        ignore=['www/assets/*', 'www/live-data/*'])

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE})
コード例 #23
0
ファイル: __init__.py プロジェクト: isabella232/liveblog-1
def deploy_liveblog():
    """
    Renders and deploys the liveblog and preview html
    """
    require('settings', provided_by=[production, staging])

    render.render_liveblog()
    flat.deploy_folder(
        app_config.S3_BUCKET,
        '.liveblog',
        '%s%s' %
        (app_config.LIVEBLOG_DIRECTORY_PREFIX, app_config.CURRENT_LIVEBLOG),
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})

    # TODO turn backup on inauguration day
    if app_config.DEPLOYMENT_TARGET == 'production':
        execute('deploy_liveblog_backup')
コード例 #24
0
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if env.get('deploy_to_servers', False):
        require('branch', provided_by=[stable, master, branch])

    if (env.settings == 'production' and env.branch != 'stable'):
        _confirm("You are trying to deploy the '%(branch)s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env)

    render_pages()
    _gzip_www()

    print app_config.S3_BUCKET

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=20'
        },
        ignore=['www/assets/*', 'www/live-data/*']
    )

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=86400'
        }
    )

    if env['deploy_to_servers']:
        checkout_latest(remote)

        if env['deploy_crontab']:
            install_crontab()

        if env['deploy_services']:
            deploy_confs()
コード例 #25
0
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
            utils.confirm(
                colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")
            )

        servers.checkout_latest(remote)

        servers.fabcast('text.update')
        servers.fabcast('assets.sync')
        servers.fabcast('data.update')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        'www',
        app_config.PROJECT_SLUG,
        max_age=app_config.DEFAULT_MAX_AGE,
        ignore=['www/assets/*', 'www/live-data/*']
    )

    flat.deploy_folder(
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        max_age=app_config.ASSETS_MAX_AGE
    )
コード例 #26
0
def deploy(path, slug=None):
    """
    manual deploy parts of a project that needs fixing
    """
    require('settings', provided_by=[production, staging])

    if not slug:
        slug = path

    utils.confirm(
        colored(
            "You are trying to override parts of %s project in %s.\n"
            "Do you know what you're doing?" % (slug, env.settings), "red"))

    flat.deploy_folder(
        app_config.S3_BUCKET,
        path,
        slug,
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})
コード例 #27
0
ファイル: theme.py プロジェクト: vdedyukhin/lookatthis
def deploy():
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=['production', 'staging'])
    require('static_path', provided_by=['tumblr'])

    execute('update')
    render()

    flat.deploy_folder('%s/www' % env.static_path,
                       '%s/%s' % (app_config.PROJECT_SLUG, env.static_path),
                       max_age=app_config.DEFAULT_MAX_AGE,
                       ignore=['%s/www/assets/*' % env.static_path])

    flat.deploy_folder('%s/www/assets' % env.static_path,
                       '%s/%s/assets' %
                       (app_config.PROJECT_SLUG, env.static_path),
                       max_age=app_config.ASSETS_MAX_AGE)
コード例 #28
0
ファイル: __init__.py プロジェクト: jimlondon/lookatthis
def deploy(slug=''):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[staging, production])
    require('slug', provided_by=[post])

    update()
    render.render_all()

    flat.deploy_folder('%s/www' % env.static_path,
                       '%s/%s' % (env.post_root, env.post_config.DEPLOY_SLUG),
                       max_age=app_config.DEFAULT_MAX_AGE,
                       ignore=['%s/www/assets/*' % env.static_path])

    flat.deploy_folder('%s/www/assets' % env.static_path,
                       '%s/%s/assets' %
                       (env.post_root, env.post_config.DEPLOY_SLUG),
                       max_age=app_config.ASSETS_MAX_AGE,
                       warn_threshold=app_config.WARN_THRESHOLD)
コード例 #29
0
ファイル: __init__.py プロジェクト: TheLens/lunchbox
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging, electron])

    render.render_all()

    if env.settings == 'electron':
        if not os.path.exists('electron'):
            os.makedirs('electron')

        local('npm run-script pack')

    if env.settings == 'fileserver':
        local('rsync -vr www/ %s@%s:%s/%s' % (
            app_config.FILE_SERVER_USER,
            app_config.FILE_SERVER,
            app_config.FILE_SERVER_PATH,
            app_config.PROJECT_SLUG
        ))

    if env.settings == 'production' or env.settings == 'staging':
        flat.deploy_folder(
            app_config.S3_BUCKET,
            'www',
            app_config.PROJECT_SLUG,
            headers={
                'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
            },
            ignore=['www/img/*', 'www/live-data/*']
        )

        flat.deploy_folder(
            app_config.S3_BUCKET,
            'www/img',
            '%s/img' % app_config.PROJECT_SLUG,
            headers={
                'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
            }
        )
コード例 #30
0
ファイル: __init__.py プロジェクト: NHagar/quotecard-maker
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging, electron])

    render.render_all()

    if env.settings == 'electron':
        if not os.path.exists('electron'):
            os.makedirs('electron')

        local('npm run-script pack')

    if env.settings == 'fileserver':
        local('rsync -vr www/ %s@%s:%s/%s' % (
            app_config.FILE_SERVER_USER,
            app_config.FILE_SERVER,
            app_config.FILE_SERVER_PATH,
            app_config.PROJECT_SLUG
        ))

    if env.settings == 'production' or env.settings == 'staging':
        flat.deploy_folder(
            app_config.S3_BUCKET,
            'www',
            app_config.PROJECT_SLUG,
            headers={
                'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
            },
            ignore=['www/img/*', 'www/live-data/*']
        )

        flat.deploy_folder(
            app_config.S3_BUCKET,
            'www/img',
            '%s/img' % app_config.PROJECT_SLUG,
            headers={
                'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
            }
        )
コード例 #31
0
def reset_browsers():
    """
    Deploy a timestamp so the client will reset their page. For bugfixes
    """
    require('settings', provided_by=[production, staging])

    if not os.path.exists('www/live-data'):
        os.makedirs('www/live-data')

    payload = {}
    now = datetime.now().strftime('%s')
    payload['timestamp'] = now

    with open('www/live-data/timestamp.json', 'w') as f:
        json.dump(payload, f)

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/live-data',
        '%s/live-data' % app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})
コード例 #32
0
ファイル: __init__.py プロジェクト: silvashih/lunchbox
def deploy(remote="origin", reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require("settings", provided_by=[production, staging, electron])

    render.render_all()

    if env.settings == "electron":
        if not os.path.exists("electron"):
            os.makedirs("electron")

        local("npm run-script pack")

    if env.settings == "fileserver":
        local(
            "rsync -vr www/ %s@%s:%s/%s"
            % (
                app_config.FILE_SERVER_USER,
                app_config.FILE_SERVER,
                app_config.FILE_SERVER_PATH,
                app_config.PROJECT_SLUG,
            )
        )

    if env.settings == "production" or env.settings == "staging":
        flat.deploy_folder(
            app_config.S3_BUCKET,
            "www",
            app_config.PROJECT_SLUG,
            headers={"Cache-Control": "max-age=%i" % app_config.DEFAULT_MAX_AGE},
            ignore=["www/img/*", "www/live-data/*"],
        )

        flat.deploy_folder(
            app_config.S3_BUCKET,
            "www/img",
            "%s/img" % app_config.PROJECT_SLUG,
            headers={"Cache-Control": "max-age=%i" % app_config.ASSETS_MAX_AGE},
        )
コード例 #33
0
ファイル: theme.py プロジェクト: BenHeubl/lookatthis
def deploy():
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=['production', 'staging'])
    require('static_path', provided_by=['tumblr'])

    execute('update')
    render()

    flat.deploy_folder(
        '%s/www' % env.static_path,
        '%s/%s' % (app_config.PROJECT_SLUG, env.static_path),
        max_age=app_config.DEFAULT_MAX_AGE,
        ignore=['%s/www/assets/*' % env.static_path]
    )

    flat.deploy_folder(
        '%s/www/assets' % env.static_path,
        '%s/%s/assets' % (app_config.PROJECT_SLUG, env.static_path),
        max_age=app_config.ASSETS_MAX_AGE
    )
コード例 #34
0
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if env.get('deploy_to_servers', False):
        require('branch', provided_by=[stable, master, branch])

    if (env.settings == 'production' and env.branch != 'stable'):
        _confirm(
            "You are trying to deploy the '%(branch)s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?"
            % env)

    render_pages()
    _gzip_www()

    print app_config.S3_BUCKET

    flat.deploy_folder(app_config.S3_BUCKET,
                       'www',
                       app_config.PROJECT_SLUG,
                       headers={'Cache-Control': 'max-age=20'},
                       ignore=['www/assets/*', 'www/live-data/*'])

    flat.deploy_folder(app_config.S3_BUCKET,
                       'www/assets',
                       '%s/assets' % app_config.PROJECT_SLUG,
                       headers={'Cache-Control': 'max-age=86400'})

    if env['deploy_to_servers']:
        checkout_latest(remote)

        if env['deploy_crontab']:
            install_crontab()

        if env['deploy_services']:
            deploy_confs()
コード例 #35
0
ファイル: __init__.py プロジェクト: BenHeubl/lookatthis
def deploy(slug=''):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[staging, production])
    require('slug', provided_by=[post])

    update()
    render.render_all()

    flat.deploy_folder(
        '%s/www' % env.static_path,
        '%s/%s' % (env.post_root, env.post_config.DEPLOY_SLUG),
        max_age=app_config.DEFAULT_MAX_AGE,
        ignore=['%s/www/assets/*' % env.static_path]
    )

    flat.deploy_folder(
        '%s/www/assets' % env.static_path,
        '%s/%s/assets' % (env.post_root, env.post_config.DEPLOY_SLUG),
        max_age=app_config.ASSETS_MAX_AGE,
        warn_threshold=app_config.WARN_THRESHOLD
    )
コード例 #36
0
ファイル: __init__.py プロジェクト: nprapps/nola
def _deploy_to_s3(path='.gzip'):
    """
    Deploy the gzipped stuff to S3.
    """
    # Clear files that should never be deployed
    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={
           'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        },
        ignore=['www/assets/*', 'www/live-data/*']
    )

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
        }
    )
コード例 #37
0
ファイル: __init__.py プロジェクト: azizjiwani/dailygraphics
def deploy(slug):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if not slug:
        print 'You must specify a project slug, like this: "deploy:slug"'
        return

    graphic_root = '%s/%s' % (app_config.GRAPHICS_PATH, slug)
    s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug)
    graphic_assets = '%s/assets' % graphic_root
    s3_assets = '%s/assets' % s3_root

    graphic_config = load_graphic_config(graphic_root)

    use_assets = getattr(graphic_config, 'USE_ASSETS', True)
    default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE
    assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE

    update_copy(slug)

    if use_assets:
        assets.sync(slug)

    render.render(slug)

    flat.deploy_folder(
        graphic_root,
        s3_root,
        headers={
            'Cache-Control': 'max-age=%i' % default_max_age
        },
        ignore=['%s/*' % graphic_assets]
    )

    # Deploy parent assets
    flat.deploy_folder(
        'www',
        app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % default_max_age
        }
    )

    if use_assets:
        flat.deploy_folder(
            graphic_assets,
            s3_assets,
            headers={
                'Cache-Control': 'max-age=%i' % assets_max_age
            }
        )

    print ''
    print '%s URL: %s/graphics/%s/' % (env.settings.capitalize(), app_config.S3_BASE_URL, slug)
コード例 #38
0
ファイル: __init__.py プロジェクト: vdedyukhin/elections16
def deploy_client(reload=False):
    """
    Deploy the latest app to S3.
    """
    require('settings', provided_by=[production, staging])

    update()
    render.render_all()
    render.render_current_state(folder='www')

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        '',
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        },
        ignore=['www/assets/*', 'www/live-data/*']
    )

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        'assets',
        headers={
            'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
        }
    )

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
コード例 #39
0
ファイル: __init__.py プロジェクト: nprapps/leadpipes
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    update()
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        },
        ignore=['www/assets/*', 'www/live-data/*']
    )

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
        }
    )

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
コード例 #40
0
def reset_browsers():
    """
    Deploy a timestamp so the client will reset their page. For bugfixes
    """
    require('settings', provided_by=[production, staging])

    if not os.path.exists('www/live-data'):
        os.makedirs('www/live-data')

    payload = {}
    now = datetime.now().strftime('%s')
    payload['timestamp'] = now

    with open('www/live-data/timestamp.json', 'w') as f:
        json.dump(payload, f)

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/live-data',
        '%s/live-data' % app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        }
    )
コード例 #41
0
ファイル: __init__.py プロジェクト: brmayes/dailygraphics-kit
def deploy_single(slug):
    """
    Deploy a single project to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    graphic_root = '%s/%s' % (app_config.GRAPHICS_PATH, slug)
    s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug)
    graphic_assets = '%s/assets' % graphic_root
    s3_assets = '%s/assets' % s3_root

    graphic_config = load_graphic_config(graphic_root)

    use_assets = getattr(graphic_config, 'USE_ASSETS', True)
    default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE
    assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE

    update_copy(slug)

    if use_assets:
        assets.sync(slug)

    render.render(slug)

    flat.deploy_folder(
        graphic_root,
        s3_root,
        headers={
            'Cache-Control': 'max-age=%i' % default_max_age
        },
        ignore=['%s/*' % graphic_assets]
    )

    # Deploy parent assets
    flat.deploy_folder(
        'www',
        app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % default_max_age
        }
    )

    if use_assets:
        flat.deploy_folder(
            graphic_assets,
            s3_assets,
            headers={
                'Cache-Control': 'max-age=%i' % assets_max_age
            }
        )

    print ''
    print '%s URL: %s/graphics/%s/' % (env.settings.capitalize(), app_config.S3_BASE_URL, slug)
コード例 #42
0
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
            utils.confirm(
                colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")
            )

        servers.checkout_latest(remote)

        servers.fabcast('text.update')
        servers.fabcast('assets.sync')
        servers.fabcast('data.update')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        'www',
        app_config.PROJECT_SLUG,
        max_age=app_config.DEFAULT_MAX_AGE,
        ignore=['www/assets/*']
    )

    flat.deploy_folder(
        '.briefings_html',
        app_config.PROJECT_SLUG,
        max_age=app_config.DEFAULT_MAX_AGE,
    )

    flat.deploy_folder(
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        max_age=app_config.ASSETS_MAX_AGE
    )
コード例 #43
0
ファイル: __init__.py プロジェクト: BenHeubl/dailygraphics
def deploy(slug):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require("settings", provided_by=[production, staging])

    if not slug:
        print 'You must specify a project slug, like this: "deploy:slug"'
        return

    graphic_root = "%s/%s" % (app_config.GRAPHICS_PATH, slug)
    s3_root = "%s/graphics/%s" % (app_config.PROJECT_SLUG, slug)
    graphic_assets = "%s/assets" % graphic_root
    s3_assets = "%s/assets" % s3_root

    graphic_config = _graphic_config(slug)

    use_assets = getattr(graphic_config, "USE_ASSETS", True)
    default_max_age = getattr(graphic_config, "DEFAULT_MAX_AGE", None) or app_config.DEFAULT_MAX_AGE
    assets_max_age = getattr(graphic_config, "ASSETS_MAX_AGE", None) or app_config.ASSETS_MAX_AGE

    update_copy(slug)

    if use_assets:
        assets.sync(slug)

    render.render(slug)

    flat.deploy_folder(
        graphic_root,
        s3_root,
        headers={"Cache-Control": "max-age=%i" % default_max_age},
        ignore=["%s/*" % graphic_assets],
    )

    # Deploy parent assets
    flat.deploy_folder("www", app_config.PROJECT_SLUG, headers={"Cache-Control": "max-age=%i" % default_max_age})

    if use_assets:
        flat.deploy_folder(graphic_assets, s3_assets, headers={"Cache-Control": "max-age=%i" % assets_max_age})

    print ""
    print "%s URL: %s/graphics/%s/" % (env.settings.capitalize(), app_config.S3_BASE_URL, slug)
コード例 #44
0
ファイル: __init__.py プロジェクト: lexieheinle/dailygraphics
def deploy_single(path):
    """
    Deploy a single project to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])
    SLACK_TOKEN = os.environ.get('SLACK_TOKEN')

    if SLACK_TOKEN == None:
        print "Can't find the Slack Token. Source your bash."
        return

    slack_client = SlackClient(SLACK_TOKEN)
    slug, abspath = utils.parse_path(path)
    graphic_root = '%s/%s' % (abspath, slug)
    s3_root = '%s/%s' % (app_config.PROJECT_SLUG, slug)
    graphic_assets = '%s/assets' % graphic_root
    s3_assets = '%s/assets' % s3_root
    graphic_node_modules = '%s/node_modules' % graphic_root

    graphic_config = load_graphic_config(graphic_root)

    use_assets = getattr(graphic_config, 'USE_ASSETS', True)
    default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE
    assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE
    update_copy(path)
    if use_assets:
        error = assets.sync(path)
        if error:
            return

    render.render(path)
    flat.deploy_folder(
        graphic_root,
        s3_root,
        headers={
            'Cache-Control': 'max-age=%i' % default_max_age
        },
        ignore=['%s/*' % graphic_assets, '%s/*' % graphic_node_modules,
                # Ignore files unused on static S3 server
                '*.xls', '*.xlsx', '*.pyc', '*.py', '*.less', '*.bak',
                '%s/base_template.html' % graphic_root,
                '%s/child_template.html' % graphic_root]
    )

    if use_assets:
        flat.deploy_folder(
            graphic_assets,
            s3_assets,
            headers={
                'Cache-Control': 'max-age=%i' % assets_max_age
            },
            ignore=['%s/private/*' % graphic_assets]
        )
    def get_start_message(slug):
        result = slack_client.api_call(
            "search.messages",
            query= '{0} in:charts'.format(slug),
        )
        if result['messages']['matches'][0].get('attachments') != None:
            print 'found attachments'
            if result['messages']['matches'][0]['attachments'][0]['title'] == slug:
                print 'found it'
                return result['messages']['matches'][0]['ts']
        if result['messages']['matches'][0].get('previous') != None:
            print 'found previous'
            if 'attachments' in result['messages']['matches'][0]['previous']:
                if result['messages']['matches'][0]['previous']['attachments'][0]['title'] == slug:
                    print 'found in previous mention'
                    return result['messages']['matches'][0]['previous']['ts']
        if result['messages']['matches'][0].get('previous_2') != None:
            print 'its in previous_2'
            if 'attachments' in result['messages']['matches'][0]['previous_2']:
                print 'attachemnts in prevous_2 '
                if result['messages']['matches'][0]['previous_2']['attachments'][0]['title'] == slug:
                    print 'found in previous_2 mention'
                    return result['messages']['matches'][0]['previous_2']['ts']
        else:
            print('Not found')
            print(result['messages']['matches'][0])
    def send_thread_message(message, ts):
            slack_client.api_call(
                "chat.postMessage",
                channel='#charts',
                text=message,
                username='******',
                icon_emoji=':bowtie:',
                thread_ts=ts,
        )
    if env.settings == 'production':
        message = 'Updated final link'
    else:
        message = 'Updated review link'
    """message_search_results = get_start_message(slug)
    if message_search_results != None:
        send_thread_message(message, message_search_results)
        print 'message sent'"""
    print ''
    print '%s URL: %s/%s/index.html' % (env.settings.capitalize(), app_config.S3_BASE_URL, slug)
コード例 #45
0
ファイル: __init__.py プロジェクト: TheLens/dailygraphics
def deploy_single(slug):
    """
    Deploy a single project to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    graphic_root = '%s/%s' % (app_config.GRAPHICS_PATH, slug)
    s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug)
    graphic_assets = '%s/assets' % graphic_root
    s3_assets = '%s/assets' % s3_root

    # New to The Lens. Check if fallback image has been created
    if not os.path.isfile('%s/fallback.png' % graphic_root):
        print 'Render a fallback image before deploying. ' + \
            'Run "fab render.save_fallback_image:slug".'
        return

    graphic_config = load_graphic_config(graphic_root)

    use_assets = getattr(graphic_config, 'USE_ASSETS', True)
    default_max_age = getattr(
        graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE
    assets_max_age = getattr(
        graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE

    update_copy(slug)

    if use_assets:
        assets.sync(slug)

    render.render(slug)

    flat.deploy_folder(
        graphic_root,
        s3_root,
        headers={
            'Cache-Control': 'max-age=%i' % default_max_age
        },
        ignore=['%s/*' % graphic_assets]
    )

    # Deploy parent assets
    flat.deploy_folder(
        'www',
        app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % default_max_age
        }
    )

    if use_assets:
        flat.deploy_folder(
            graphic_assets,
            s3_assets,
            headers={
                'Cache-Control': 'max-age=%i' % assets_max_age
            }
        )

    print '\n%s URL: %s/graphics/%s/' % (
        env.settings.capitalize(), app_config.S3_BASE_URL, slug)