Ejemplo n.º 1
0
#!/usr/bin/env python
# pylint: disable=import-error
"""
Save all collections to update calculated fields.
"""

import os

from crowdsorter.settings import get_config
from crowdsorter.factory import create_app
from crowdsorter.models import Collection

create_app(get_config(os.getenv('FLASK_ENV') or 'dev'))

for collection in Collection.objects:
    collection.save()
Ejemplo n.º 2
0
import os

from flask_script import Manager, Server

from crowdsorter.settings import get_config
from crowdsorter.factory import create_app


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


config = get_config(os.getenv('FLASK_ENV'))

app = create_app(config)

server = Server(extra_files=find_assets())

manager = Manager(app)
manager.add_command('run', server)

if __name__ == '__main__':
    manager.run()
Ejemplo n.º 3
0
 def when_valid():
     config = get_config('prod')
     expect(config.ENV) == 'prod'
Ejemplo n.º 4
0
 def when_unknown():
     with expect.raises(AssertionError):
         get_config('unknown')
Ejemplo n.º 5
0
 def when_empty():
     with expect.raises(AssertionError):
         get_config('')
Ejemplo n.º 6
0
def app():
    return create_app(get_config('test'))