# Path: recruit_app/app.py
# def create_app(config_object=ProdConfig):
#     '''An application factory, as explained here:
#         http://flask.pocoo.org/docs/patterns/appfactories/
# 
#     :param config_object: The configuration object to use.
#     '''
#     app = Flask(__name__)
#     app.config.from_object(config_object)
#     register_extensions(app)
#     register_blueprints(app)
#     register_errorhandlers(app)
#     admin = Admin()
#     register_admin(admin, db)
#     # register_search(app)
#     admin.init_app(app)
#     # admin needs to be initialized oddly for tests to work.
#     register_tasks()
# 
#     return app
# 
# Path: recruit_app/settings.py
# class DevConfig(Config):
#     """Development configuration."""
#     ENV = 'dev'
#     DEBUG = True
#     #DB_NAME = 'dev.db'
#     # Put the db file in project root
#     #DB_PATH = os.path.join(Config.PROJECT_ROOT, DB_NAME)
#     SQLALCHEMY_DATABASE_URI = os_env.get('DATABASE_URL', 'postgresql://recruit@localhost:5432/recruit')
#     #SQLALCHEMY_DATABASE_URI = 'sqlite:///{0}'.format(DB_PATH)
#     WHOOSH_BASE = os.path.join(basedir, 'search.db')
#     #DEBUG_TB_ENABLED = True
#     ASSETS_DEBUG = True  # Don't bundle/minify static assets
#     CACHE_TYPE = 'simple'  # Can be "memcached", "redis", etc.
# 
# class ProdConfig(Config):
#     """Production configuration."""
#     ENV = 'prod'
#     DEBUG = False
#     SQLALCHEMY_DATABASE_URI = os_env.get('DATABASE_URL', 'postgresql://recruit@localhost:5432/recruit')
#     DEBUG_TB_ENABLED = False  # Disable Debug toolbar
#     WHOOSH_BASE = os.path.join(basedir, 'search.db')


import argparse
import urlparse
import sys
import os
from redis import Redis
from rq_scheduler.scheduler import Scheduler
from recruit_app.app import create_app
from recruit_app.settings import DevConfig, ProdConfig
from rq.logutils import setup_loghandlers

    if args.url is not None:
        connection = Redis.from_url(args.url)

    elif os.getenv('REDISTOGO_URL'):
        redis_url = os.getenv('REDISTOGO_URL')
        if not redis_url:
            raise RuntimeError('Set up Redis To Go first.')

        urlparse.uses_netloc.append('redis')
        url = urlparse.urlparse(redis_url)
        connection = Redis(host=url.hostname, port=url.port, db=0, password=url.password)
    elif args.host is not None:
        connection = Redis(args.host, args.port, args.db, args.password)
    else:
        connection = Redis()

    if args.verbose:
        level = 'DEBUG'
    else:
        level = 'INFO'
    setup_loghandlers(level)

    scheduler = Scheduler(connection=connection, interval=args.interval)
    scheduler.run()

if __name__ == '__main__':
    if os.environ.get("RECRUIT_APP_ENV") == 'prod':
        app = create_app(ProdConfig)
    else:

# Path: recruit_app/app.py
# def create_app(config_object=ProdConfig):
#     '''An application factory, as explained here:
#         http://flask.pocoo.org/docs/patterns/appfactories/
# 
#     :param config_object: The configuration object to use.
#     '''
#     app = Flask(__name__)
#     app.config.from_object(config_object)
#     register_extensions(app)
#     register_blueprints(app)
#     register_errorhandlers(app)
#     admin = Admin()
#     register_admin(admin, db)
#     # register_search(app)
#     admin.init_app(app)
#     # admin needs to be initialized oddly for tests to work.
#     register_tasks()
# 
#     return app
# 
# Path: recruit_app/settings.py
# class DevConfig(Config):
#     """Development configuration."""
#     ENV = 'dev'
#     DEBUG = True
#     #DB_NAME = 'dev.db'
#     # Put the db file in project root
#     #DB_PATH = os.path.join(Config.PROJECT_ROOT, DB_NAME)
#     SQLALCHEMY_DATABASE_URI = os_env.get('DATABASE_URL', 'postgresql://recruit@localhost:5432/recruit')
#     #SQLALCHEMY_DATABASE_URI = 'sqlite:///{0}'.format(DB_PATH)
#     WHOOSH_BASE = os.path.join(basedir, 'search.db')
#     #DEBUG_TB_ENABLED = True
#     ASSETS_DEBUG = True  # Don't bundle/minify static assets
#     CACHE_TYPE = 'simple'  # Can be "memcached", "redis", etc.
# 
# class ProdConfig(Config):
#     """Production configuration."""
#     ENV = 'prod'
#     DEBUG = False
#     SQLALCHEMY_DATABASE_URI = os_env.get('DATABASE_URL', 'postgresql://recruit@localhost:5432/recruit')
#     DEBUG_TB_ENABLED = False  # Disable Debug toolbar
#     WHOOSH_BASE = os.path.join(basedir, 'search.db')


# Path: run_scheduler.py
import argparse
import urlparse
import sys
import os
from redis import Redis
from rq_scheduler.scheduler import Scheduler
from recruit_app.app import create_app
from recruit_app.settings import DevConfig, ProdConfig
from rq.logutils import setup_loghandlers


    if args.url is not None:
        connection = Redis.from_url(args.url)

    elif os.getenv('REDISTOGO_URL'):
        redis_url = os.getenv('REDISTOGO_URL')
        if not redis_url:
            raise RuntimeError('Set up Redis To Go first.')

        urlparse.uses_netloc.append('redis')
        url = urlparse.urlparse(redis_url)
        connection = Redis(host=url.hostname, port=url.port, db=0, password=url.password)
    elif args.host is not None:
        connection = Redis(args.host, args.port, args.db, args.password)
    else:
        connection = Redis()

    if args.verbose:
        level = 'DEBUG'
    else:
        level = 'INFO'
    setup_loghandlers(level)

    scheduler = Scheduler(connection=connection, interval=args.interval)
    scheduler.run()

if __name__ == '__main__':
    if os.environ.get("RECRUIT_APP_ENV") == 'prod':
        app = create_app(ProdConfig)
    else:

        app = create_app(DevConfig)