# Path: suma/core/models/meta/base.py
# def create_dbsession(engine):
#     dbsession = scoped_session(sessionmaker())
#     dbsession.configure(bind=engine)
#     Base.metadata.bind = engine
#     return dbsession


from optparse import make_option
from celery import signals, Celery
from pyramid.paster import bootstrap, get_appsettings
from sqlalchemy import create_engine
from celery import Task
from celery.loaders.base import BaseLoader
from suma.core.models.meta import create_dbsession
from paste.deploy.converters import aslist, asbool
        from suma.core.services import (
            LinkService,
            HashIdService,
            ScreenshotService,
            LocalFileService,
            S3FileService,
            StatService
        )
from __future__ import absolute_import

celery = Celery()

celery.user_options['preload'].add(
    make_option(
        '-i', '--ini',
        default=None,
        help='Paste ini configuration file.'),
)


class INILoader(BaseLoader):

    def __init__(self, app, **kwargs):
        self.celery_conf = kwargs.pop('ini_file')

        super(INILoader, self).__init__(app, **kwargs)

    def read_configuration(self, fail_silently=True):
        config_dict = {}

        for key, value in get_appsettings(self.celery_conf).items():
            if key.lower().startswith('celery.'):
                config_dict[key[7:].upper()] = value


# Path: suma/core/models/meta/base.py
# def create_dbsession(engine):
#     dbsession = scoped_session(sessionmaker())
#     dbsession.configure(bind=engine)
#     Base.metadata.bind = engine
#     return dbsession


# Path: suma/celery.py
from optparse import make_option
from celery import signals, Celery
from pyramid.paster import bootstrap, get_appsettings
from sqlalchemy import create_engine
from celery import Task
from celery.loaders.base import BaseLoader
from suma.core.models.meta import create_dbsession
from paste.deploy.converters import aslist, asbool
        from suma.core.services import (
            LinkService,
            HashIdService,
            ScreenshotService,
            LocalFileService,
            S3FileService,
            StatService
        )

from __future__ import absolute_import

celery = Celery()

celery.user_options['preload'].add(
    make_option(
        '-i', '--ini',
        default=None,
        help='Paste ini configuration file.'),
)


class INILoader(BaseLoader):

    def __init__(self, app, **kwargs):
        self.celery_conf = kwargs.pop('ini_file')

        super(INILoader, self).__init__(app, **kwargs)

    def read_configuration(self, fail_silently=True):
        config_dict = {}

        for key, value in get_appsettings(self.celery_conf).items():
            if key.lower().startswith('celery.'):
                config_dict[key[7:].upper()] = value


        config_dict['CELERY_IMPORTS'] = [