示例#1
0
def app():
    return create_app(get_config('test'))
示例#2
0
    def run(self):
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ['static', 'templates']:
        directory = os.path.join(app.config['PATH'], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv('FLASK_CONFIG', 'dev'))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command('validate', Validate())
manager.add_command('run', Server(host='0.0.0.0', extra_files=find_assets()))

if __name__ == '__main__':
    manager.run()
示例#3
0
 def when_empty(expect):
     with expect.raises(AssertionError):
         get_config('')
示例#4
0
 def when_valid(expect):
     config = get_config('production')
     expect(config.ENV) == 'production'
示例#5
0
 def test_get_valid(self):
     config = get_config('prod')
     assert issubclass(config, Config)
 def app():
     app = create_app(get_config('test'))
     app.config['GOOGLE_ANALYTICS_TID'] = 'my_tid'
     return app
示例#7
0
 def app():
     app = create_app(get_config("test"))
     app.config["GOOGLE_ANALYTICS_TID"] = "my_tid"
     return app
示例#8
0
 def test_get_none(self):
     with pytest.raises(AssertionError):
         get_config('')
示例#9
0
 def when_unknown(expect):
     with expect.raises(AssertionError):
         get_config('unknown')
示例#10
0
 def when_valid(expect):
     config = get_config('production')
     expect(config.ENV) == 'production'
示例#11
0
 def when_empty(expect):
     with expect.raises(AssertionError):
         get_config('')
示例#12
0
 def when_extended(expect):
     config = get_config('staging')
     expect(config.ENV) == 'staging'
示例#13
0
    """Checks for issues in all templates."""
    def run(self):  # pylint: disable=method-hidden
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ['static', 'templates']:
        directory = os.path.join(app.config['PATH'], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv('FLASK_ENV', 'local'))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command('validate', Validate())
manager.add_command('run', Server(extra_files=find_assets()))

if __name__ == '__main__':
    manager.run()
示例#14
0
 def test_get_unknown(self):
     with pytest.raises(AssertionError):
         get_config('not_a_valid_config')
示例#15
0
文件: manage.py 项目: kyluca/memegen
    def run(self):  # pylint: disable=method-hidden
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ['static', 'templates']:
        directory = os.path.join(app.config['PATH'], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv('FLASK_ENV', 'local'))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command('validate', Validate())
manager.add_command('run', Server(extra_files=find_assets()))


if __name__ == '__main__':
    manager.run()
def unset(name):
    config = get_config('test')
    if getattr(config, name):
        return dict(condition=False, reason="")
    else:
        return dict(condition=True, reason="{} unset".format(name))
示例#17
0
#!env/bin/python

import os
import logging

from flask_script import Manager, Server

from memegen.settings import get_config
from memegen.app import create_app


config = get_config(os.getenv('CONFIG'))
app = create_app(config)
manager = Manager(app)


@manager.command
def validate():
    if app.template_service.validate():
        return 0
    else:
        return 1


manager.add_command('server', Server(host='0.0.0.0'))


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO,
                        format="%(levelname)s: %(message)s")
    logging.getLogger('yorm').setLevel(logging.WARNING)
示例#18
0
 def test_get_unknown(self):
     with pytest.raises(AssertionError):
         get_config('not_a_valid_config')
示例#19
0
    def run(self):
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ["static", "templates"]:
        directory = os.path.join(app.config["PATH"], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv("FLASK_CONFIG", "dev"))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command("validate", Validate())
manager.add_command("run", Server(host="0.0.0.0", extra_files=find_assets()))


if __name__ == "__main__":
    manager.run()
示例#20
0
 def app():
     app = create_app(get_config('test'))
     app.config['GOOGLE_ANALYTICS_TID'] = 'my_tid'
     return app
示例#21
0
文件: manage.py 项目: kpantic/memegen
#!env/bin/python

import os
import logging

from flask_script import Manager, Server

from memegen.settings import get_config
from memegen.app import create_app

config = get_config(os.getenv('CONFIG'))
app = create_app(config)
manager = Manager(app)


@manager.command
def validate():
    if app.template_service.validate():
        return 0
    else:
        return 1


manager.add_command('server', Server(host='0.0.0.0'))

if __name__ == '__main__':
    manager.run()
示例#22
0
 def when_extended(expect):
     config = get_config('staging')
     expect(config.ENV) == 'staging'
示例#23
0
def app():
    yield create_app(get_config('test'))
示例#24
0
 def when_unknown(expect):
     with expect.raises(AssertionError):
         get_config('unknown')
示例#25
0
#!env/bin/python

import os
import logging
from subprocess import check_output

from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand

from memegen.settings import get_config
from memegen.app import create_app

# Select app configuration from the environment
config = get_config(os.getenv('CONFIG', 'dev'))

# Build the app using configuration from the environment
app = create_app(config)

# Populate unset environment variables
for name, command in [
    ('DEPLOY_DATE', "TZ=America/Detroit date '+%F %T'"),
]:
    output = check_output(command, shell=True, universal_newlines=True).strip()
    os.environ[name] = os.getenv(name, output)

# Configure the command-line interface
manager = Manager(app)


@manager.command
def validate():
示例#26
0
def app():
    app = create_app(get_config('test'))
    yield app
def unset(name):
    config = get_config('test')
    if getattr(config, name):
        return dict(condition=False, reason="")
    else:
        return dict(condition=True, reason="{} unset".format(name))
示例#28
0
def app():
    yield create_app(get_config('test'))
示例#29
0
文件: manage.py 项目: dvelle/memegen
#!env/bin/python

import os
import subprocess
import logging

from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand
from whitenoise import WhiteNoise

from memegen.settings import get_config
from memegen.app import create_app


# Select app configuration from the environment
config = get_config(os.getenv('CONFIG', 'dev'))

# Build the app using configuration from the environment
_app = create_app(config)

# Populate unset environment variables
for name, command in [
    ('DEPLOY_DATE', "TZ=America/Detroit date '+%F %T'"),
]:
    output = subprocess.run(command, shell=True, stdout=subprocess.PIPE,
                            universal_newlines=True).stdout.strip() or "???"
    os.environ[name] = os.getenv(name, output)

# Configure the command-line interface
manager = Manager(_app)
示例#30
0
 def test_get_none(self):
     with pytest.raises(AssertionError):
         get_config('')
示例#31
0
def app():
    app = create_app(get_config('test'))
    yield app
示例#32
0
    def test_get_valid(self):
        config = get_config('prod')

        assert issubclass(config, Config)
        assert 'prod' == config.ENV
示例#33
0
def app(postgres):
    app = create_app(get_config('test'))
    app.config['SQLALCHEMY_DATABASE_URI'] = postgres.url()
    yield app