Esempio n. 1
0
def init_celery_flask_app(**kwargs):
    """Create the Flask app after forking a new worker.

    This is to make sure no resources are shared between processes.
    """
    app = create_app()
    app.app_context().push()
Esempio n. 2
0
def create(group):
    app = current_app or create_app()
    group.app = app

    @app.shell_context_processor
    def shell_context():
        from redash import models
        return dict(models=models)

    return app
Esempio n. 3
0
 def setUp(self):
     self.app = create_app()
     self.db = db
     self.app.config['TESTING'] = True
     self.app_ctx = self.app.app_context()
     self.app_ctx.push()
     db.session.close()
     db.drop_all()
     db.create_all()
     self.factory = Factory()
     self.client = self.app.test_client()
Esempio n. 4
0
 def setUp(self):
     self.app = create_app()
     self.db = db
     self.app.config['TESTING'] = True
     self.app.config['SERVER_NAME'] = 'localhost'
     self.app_ctx = self.app.app_context()
     self.app_ctx.push()
     db.session.close()
     db.drop_all()
     db.create_all()
     self.factory = Factory()
     self.client = self.app.test_client()
Esempio n. 5
0
def create(group):
    app = current_app or create_app()
    group.app = app

    @app.shell_context_processor
    def shell_context():
        from redash import models, settings
        return {
            'models': models,
            'settings': settings,
        }
    return app
Esempio n. 6
0
def create(group):
    app = current_app or create_app()
    group.app = app

    @app.shell_context_processor
    def shell_context():
        from redash import models, settings
        return {
            'models': models,
            'settings': settings,
        }
    return app
Esempio n. 7
0
 def test_render(self):
     app = create_app()
     with app.app_context():
         d = {
             "failures": [{
                 "id": 1,
                 "name": "Failure Unit Test",
                 "failed_at": "May 04, 2021 02:07PM UTC",
                 "failure_reason": "",
                 "failure_count": 1,
                 "comment": None
             }]
         }
         html, text = [
             render_template("emails/failures.{}".format(f), d)
             for f in ["html", "txt"]
         ]
         self.assertIn('Failure Unit Test', html)
         self.assertIn('Failure Unit Test', text)
Esempio n. 8
0
def init_celery_flask_app(**kwargs):
    app = create_app()
    app.app_context().push()
Esempio n. 9
0
# -*- coding: utf-8 -*-
from redash import create_app

app = create_app()
Esempio n. 10
0
def init_celery_flask_app(**kwargs):
    app = create_app()
    app.app_context().push()
Esempio n. 11
0
def add_periodic_tasks(sender, **kwargs):
    app = create_app()
    periodic_tasks = getattr(app, 'periodic_tasks', {})
    for params in periodic_tasks.values():
        sender.add_periodic_task(**params)
Esempio n. 12
0
 def __call__(self, *args, **kwargs):
     app = create_app()
     with app.app_context():
         return TaskBase.__call__(self, *args, **kwargs)
Esempio n. 13
0
from redash import create_app

app = create_app()

Esempio n. 14
0
def add_periodic_tasks(sender, **kwargs):
    app = create_app()
    periodic_tasks = getattr(app, 'periodic_tasks', {})
    for params in periodic_tasks.values():
        sender.add_periodic_task(**params)
Esempio n. 15
0
 def __call__(self, *args, **kwargs):
     if not has_app_context():
         flask_app = current_app or create_app()
         self.app_ctx = flask_app.app_context()
         self.app_ctx.push()
     return super(BaseTask, self).__call__(*args, **kwargs)
Esempio n. 16
0
def create(group):
    app = create_app()
    group.app = app
    return app