예제 #1
0
def update():
    """
    Update all application data not in repository (copy, assets, etc).
    """
    text.update()
    assets.sync()
    data.update()
예제 #2
0
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
        }
    )
def update():
    """
    Update all application data not in repository (copy, assets, etc).
    """
    text.update()
    assets.sync()
    data.update()
예제 #4
0
def render():
    """
    Render HTML templates and compile assets.
    """
    from flask import g

    update_copy()
    assets.sync()
    update_data()
    less()
    jst()

    app_config_js()
    copy_js()

    compiled_includes = []

    for rule in app.app.url_map.iter_rules():
        rule_string = rule.rule
        name = rule.endpoint

        if name == "static" or name.startswith("_"):
            print "Skipping %s" % name
            continue

        if rule_string.endswith("/"):
            filename = "www" + rule_string + "index.html"
        elif rule_string.endswith(".html"):
            filename = "www" + rule_string
        else:
            print "Skipping %s" % name
            continue

        dirname = os.path.dirname(filename)

        if not (os.path.exists(dirname)):
            os.makedirs(dirname)

        print "Rendering %s" % (filename)

        with app.app.test_request_context(path=rule_string):
            g.compile_includes = True
            g.compiled_includes = compiled_includes

            bits = name.split(".")

            # Determine which module the view resides in
            if len(bits) > 1:
                module, name = bits
            else:
                module = "app"

            view = globals()[module].__dict__[name]
            content = view()

            compiled_includes = g.compiled_includes

        with open(filename, "w") as f:
            f.write(content.encode("utf-8"))
예제 #5
0
def render():
    """
    Render HTML templates and compile assets.
    """
    from flask import g

    update_copy()
    assets.sync()
    update_data()
    less()
    jst()

    app_config_js()
    copy_js()

    compiled_includes = []

    for rule in app.app.url_map.iter_rules():
        rule_string = rule.rule
        name = rule.endpoint

        if name == 'static' or name.startswith('_'):
            print 'Skipping %s' % name
            continue

        if rule_string.endswith('/'):
            filename = 'www' + rule_string + 'index.html'
        elif rule_string.endswith('.html'):
            filename = 'www' + rule_string
        else:
            print 'Skipping %s' % name
            continue

        dirname = os.path.dirname(filename)

        if not (os.path.exists(dirname)):
            os.makedirs(dirname)

        print 'Rendering %s' % (filename)

        with app.app.test_request_context(path=rule_string):
            g.compile_includes = True
            g.compiled_includes = compiled_includes

            bits = name.split('.')

            # Determine which module the view resides in
            if len(bits) > 1:
                module, name = bits
            else:
                module = 'app'

            view = globals()[module].__dict__[name]
            content = view()

            compiled_includes = g.compiled_includes

        with open(filename, 'w') as f:
            f.write(content.encode('utf-8'))
예제 #6
0
def render():
    """
    Render HTML templates and compile assets.
    """
    from flask import g

    #update_copy()
    assets.sync()
    update_data()
    less()
    jst()

    app_config_js()
    copy_js()

    compiled_includes = []

    for rule in app.app.url_map.iter_rules():
        rule_string = rule.rule
        name = rule.endpoint

        if name == 'static' or name.startswith('_'):
            print 'Skipping %s' % name
            continue

        if rule_string.endswith('/'):
            filename = 'www' + rule_string + 'index.html'
        elif rule_string.endswith('.html'):
            filename = 'www' + rule_string
        else:
            print 'Skipping %s' % name
            continue

        dirname = os.path.dirname(filename)

        if not (os.path.exists(dirname)):
            os.makedirs(dirname)

        print 'Rendering %s' % (filename)

        with app.app.test_request_context(path=rule_string):
            g.compile_includes = True
            g.compiled_includes = compiled_includes

            bits = name.split('.')

            # Determine which module the view resides in
            if len(bits) > 1:
                module, name = bits
            else:
                module = 'app'

            view = globals()[module].__dict__[name]
            content = view()

            compiled_includes = g.compiled_includes

        with open(filename, 'w') as f:
            f.write(content.encode('utf-8'))
예제 #7
0
def update():
    """
    Update all application data not in repository (copy, assets, etc).
    """
    require('slug', provided_by=[post])

    text.update()
    assets.sync()
예제 #8
0
def update():
    """
    Update all application data not in repository (copy, assets, etc).
    """
    require('slug', provided_by=[post])

    text.update()
    assets.sync()
예제 #9
0
def update():
    """
    Update all application data not in repository (copy, assets, etc).
    """
    utils.install_font(force=False)
    text.update()
    assets.sync()
    data.update()
예제 #10
0
def update():
    """
    Update all application data not in repository (copy, assets, etc).
    """
    utils.install_font(force=False)
    text.update()
    assets.sync()
    data.update()
예제 #11
0
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)
예제 #12
0
def local_bootstrap_data():
    """
    Sets up the app from scratch.
    """
    assets.sync()
    local_init_db()
    init_tables()
    os.system('rm -f www/live-data/audio/*.oga www/live-data/audio/*.mp3')
    load_quizzes()
예제 #13
0
def local_bootstrap_data():
    """
    Sets up the app from scratch.
    """
    assets.sync()
    local_init_db()
    init_tables()
    os.system('rm -f www/live-data/audio/*.oga www/live-data/audio/*.mp3')
    load_quizzes()
예제 #14
0
def update():
    """
    Update all application data not in repository (copy, assets, etc).
    5/23/18 - DISABLED GDOCS CONNECTION
    """
    print 'The Google Spreadsheets connection has been disabled. See project README.'
    #text.update()
    assets.sync()
    data.update()
예제 #15
0
파일: __init__.py 프로젝트: wbez/debates
def update():
    """
    Update all application data not in repository (copy, assets, etc).
    """
    utils.install_font(force=False)
    text.update()
    assets.sync()
    data.update()
    # Get google document exported as HTML
    text.get_transcript()
예제 #16
0
def update():
    """
    Update all application data not in repository (copy, assets, etc).
    """
    utils.install_font(force=False)
    text.update_copytext()
    text.update_calendar()
    text.update_newsletter()
    text.update_all_docs()
    assets.sync()
예제 #17
0
def bootstrap():
    """
    Bootstrap this project. Should only need to be run once.
    """
    # Reimport app_config in case this is part of the app_template bootstrap
    import app_config

    local(NPM_INSTALL_COMMAND)

    assets.sync()
    # update_copy()
    update_data()
예제 #18
0
파일: __init__.py 프로젝트: nprapps/visits
def bootstrap():
    """
    Bootstrap this project. Should only need to be run once.
    """
    # Reimport app_config in case this is part of the app_template bootstrap
    import app_config

    local(NPM_INSTALL_COMMAND)

    assets.sync()
    update_copy()
    update_data()
예제 #19
0
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)
예제 #20
0
def bootstrap():
    """
    Bootstrap this project. Should only need to be run once.
    """
    # Reimport app_config in case this is part of the app_template bootstrap
    import app_config

    local('npm install less universal-jst -g --prefix node_modules')

    assets.sync()
    #update_copy()
    update_data()
예제 #21
0
def bootstrap():
    """
    Bootstrap this project. Should only need to be run once.
    """
    # Reimport app_config in case this is part of the app_template bootstrap
    import app_config

    local('npm install less universal-jst -g --prefix node_modules')

    assets.sync()
    update_copy()
    update_data()
예제 #22
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)
예제 #23
0
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)
예제 #24
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)
예제 #25
0
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)
예제 #26
0
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)