コード例 #1
0
ファイル: __init__.py プロジェクト: publicscience/argos
def create_app(**config_overrides):
    app = web.create_app(__name__, __path__, **config_overrides)

    tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
    app.template_folder = tmpl_dir

    api.init_app(app)
    oauth.init_app(app)

    return app
コード例 #2
0
ファイル: __init__.py プロジェクト: publicscience/argos
def create_app(**config_overrides):
    app = web.create_app(__name__, __path__, **config_overrides)

    tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
    static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static')
    app.template_folder = tmpl_dir
    app.static_folder = static_dir

    oauth.init_app(app)
    assets.init_app(app)
    babel = Babel(app)

    # So we can use Jade templates.
    app.jinja_env.add_extension('pyjade.ext.jinja.PyJadeExtension')

    return app
コード例 #3
0
ファイル: __init__.py プロジェクト: publicscience/argos
from argos import web
from argos.web import api, front
from argos.datastore import db
from argos.tasks import workers

from tests.patches import patch_knowledge, patch_concepts, patch_aws
from tests import helpers

import numpy as np
np.seterr(invalid='ignore')

test_config = {
        'SQLALCHEMY_DATABASE_URI': 'postgresql://*****:*****@localhost:5432/argos_test'
}

bare_app = web.create_app(**test_config)
api_app = api.create_app(**test_config)
front_app = front.create_app(**test_config)

for app in [api_app, front_app]:
    app.register_blueprint(helpers.blueprint)


class RequiresMocks(unittest.TestCase):
    def create_patch(self, name, **kwargs):
        """
        Helper for patching/mocking methods.

        Args:
            | name (str)       -- the 'module.package.method' to mock.
        """
コード例 #4
0
    celery = Celery()
    celery.config_from_object(CELERY)
    TaskBase = celery.Task

    class ContextTask(TaskBase):
        abstract = True

        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)

    celery.Task = ContextTask
    return celery


app = web.create_app(__name__, __path__, has_blueprints=False)
celery = create_celery(app)


def workers():
    """
    Get info about currently available Celery workers.
    If none are available, or there are issues connecting
    to the MQ, returns False.

    Returns:
        | dict      -- dict of available workers.
        OR
        | bool      -- False if no available workers, or cannot connect ot MQ.
    """
コード例 #5
0
ファイル: __init__.py プロジェクト: publicscience/argos
    celery = Celery()
    celery.config_from_object(CELERY)
    TaskBase = celery.Task

    class ContextTask(TaskBase):
        abstract = True

        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)

    celery.Task = ContextTask
    return celery

app = web.create_app(__name__, __path__, has_blueprints=False)
celery = create_celery(app)

def workers():
    """
    Get info about currently available Celery workers.
    If none are available, or there are issues connecting
    to the MQ, returns False.

    Returns:
        | dict      -- dict of available workers.
        OR
        | bool      -- False if no available workers, or cannot connect ot MQ.
    """

    try: