コード例 #1
0
ファイル: wsgi.py プロジェクト: baijum/py-overc
def init_application(app_config_file):
    """ Initialize application from config file path
       :rtype: OvercApplication
       """
    # Load config
    app_config = OvercApplication.loadConfigFile(app_config_file)

    # Configure logging
    logging.basicConfig(level=getattr(logging, app_config['LOGLEVEL']))
    # TODO: multi-process app does not log everything fine! make it log to stdout, always

    # Applicaton
    application = OvercApplication(
        __name__,
        app_config['INSTANCE_PATH'],
        app_config
    )

    # Supervisor thread
    p = multiprocessing.Process(name='supervisor', target=supervise_loop, args=(application,))
    p.daemon = True
    p.start()

    # Finish
    return application
コード例 #2
0
ファイル: __init__.py プロジェクト: baijum/py-overc
    def setUp(self):
        # Load config
        app_config_file = 'tests/data/overc-server/server.ini'
        app_config = OvercApplication.loadConfigFile(app_config_file)

        # Init app
        self.instance_path = app_config['INSTANCE_PATH']
        self.app = OvercApplication(__name__, self.instance_path, app_config)
        self.app.app.config.update(TESTING=True)

        # Customize
        self.app.app.test_client_class = CustomFlaskClient

        # Reset DB
        models.Base.metadata.drop_all(bind=self.app.db_engine)
        models.Base.metadata.create_all(bind=self.app.db_engine)