예제 #1
0
파일: app.py 프로젝트: rtx3/deyun.io
def create_celery_app(app=None):

    from sqlalchemy import create_engine
    from sqlalchemy.orm import sessionmaker

    app = create_app()

    celery = Celery(app.__class__)
    celery.config_from_object('celery_config')

    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
    #celery.conf.update(app.config)
    app.app_context().push()

    # an Engine, which the Session will use for connection
    # resources
    celery_task = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])

    # create a configured "Session" class
    Session = sessionmaker(bind=celery_task)

    # create a Session
    session = Session()

    return celery, session
예제 #2
0
def CreateApp():
    app = Flask(__name__)
    app.config.from_object('config')
    celery.config_from_object('config')
    InitmongoDB(app)
    InitLogin(app)
    RegisterBlueprints(app)
    return app
예제 #3
0
def create_app(config=None):
    app = Flask('scaffold', instance_relative_config=True)
    if config is not None:
        app.config.from_object(config)

    init_logger(app)
    logger.info('starting %s' % app.name)
    db.init_app(app)
    cors.init_app(app)
    celery.config_from_object(app.config)
    login_manager.init_app(app)
    api.init_app(app)
    init_api(api, app)
    logger.info('started %s' % app.name)

    return app
예제 #4
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    bootstrap.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    celery.config_from_object(app.config)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    return app
예제 #5
0
파일: app.py 프로젝트: rtx3/Salt-MWDS
def create_celery_app(app=None):

    from sqlalchemy import create_engine
    from sqlalchemy.orm import sessionmaker

    app = create_app()

    celery = Celery(app.__class__)
    celery.config_from_object('celery_config')
    
    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
    #celery.conf.update(app.config)
    app.app_context().push()


    # an Engine, which the Session will use for connection
    # resources
    celery_task = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])

    # create a configured "Session" class
    Session = sessionmaker(bind=celery_task)
    
    # create a Session
    session = Session()


    return celery , session
예제 #6
0
파일: worker.py 프로젝트: rtx3/Salt-MWDS
from app import create_app
from extensions import celery
from celery_task_socket import self_test
import eventlet

'''
Enable the monkey_patch if run into a socket issue
'''
#eventlet.monkey_patch()

app = create_app()
celery.init_app(app)
celery.config_from_object('celery_socket_config')
예제 #7
0
from app import create_app
from extensions import celery
from celery_task_socket import self_test
import eventlet
'''
Enable the monkey_patch if run into a socket issue
'''
eventlet.monkey_patch()

app = create_app()
celery.init_app(app)
celery.config_from_object('celery_socket_config')
예제 #8
0
    from prod import config
except:
    pass
from functools import wraps
from utils import convert
from extensions import celery, db
from requests import post
from flask_socketio import SocketIO
from statistics import mean

#import app
#tapp,session = app.create_socket_celery()
# celery.init_app(tapp)


celery.config_from_object('celery_config')

logger = logging.getLogger('task')
logger.setLevel(10)
#celery, session = create_celery_app()

#celery.config_from_object('prod', silent=True)
# load config from celery_config.py , store other api information in prod.py


indbapi = Indb(config['INDB_HOST'] + ':' + config['INDB_PORT'])

sensuapi = SensuAPI(config['SENSU_HOST'] + ':' + config['SENSU_PORT'])

#master = session.query(Masterdb).first()
# try:
예제 #9
0
def configure_app(app):
    app.config.from_object("conf")
    celery.config_from_object(app.config)