예제 #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()
예제 #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()
예제 #3
0
 def when_valid():
     config = get_config('prod')
     expect(config.ENV) == 'prod'
예제 #4
0
 def when_unknown():
     with expect.raises(AssertionError):
         get_config('unknown')
예제 #5
0
 def when_empty():
     with expect.raises(AssertionError):
         get_config('')
예제 #6
0
def app():
    return create_app(get_config('test'))