Exemplo n.º 1
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Create app."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    queue.init_app(app)

    db.init_app(app)
    ma.init_app(app)

    api.init_app(app)
    setup_jwt_manager(app, jwt)

    nro.init_app(app)
    cache.init_app(app)
    nr_filing_actions.init_app(app)

    @app.after_request
    def add_version(response):
        os.getenv('OPENSHIFT_BUILD_COMMIT', '')
        response.headers['API'] = 'NameX/{ver}'.format(ver=run_version)
        return response

    register_shellcontext(app)

    return app
Exemplo n.º 2
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Create app."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    # Configure Sentry
    if app.config.get('SENTRY_DSN', None):
        sentry_sdk.init(dsn=app.config.get('SENTRY_DSN'),
                        integrations=[FlaskIntegration()])

    db.init_app(app)
    ma.init_app(app)

    api.init_app(app)
    setup_jwt_manager(app, jwt)

    nro.init_app(app)

    @app.after_request
    def add_version(response):
        os.getenv('OPENSHIFT_BUILD_COMMIT', '')
        response.headers['API'] = 'NameX/{ver}'.format(ver=run_version)
        return response

    register_shellcontext(app)

    return app
Exemplo n.º 3
0
def app():
    """Return a session-wide application configured in TEST mode."""
    # _app = create_app('testing')
    _app = Flask('testing')
    print(config)
    _app.config.from_object(get_named_config('testing'))
    _db.init_app(_app)

    return _app
Exemplo n.º 4
0
def app():
    """Return a session-wide application configured in TEST mode."""
    _app = Flask('testing')
    print(config)
    _app.config.from_object(get_named_config('testing'))
    _db.init_app(_app)
    queue.init_app(_app, asyncio.new_event_loop())

    return _app
Exemplo n.º 5
0
def create_app():
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(APP_CONFIG)

    queue.init_app(app)
    db.init_app(app)

    register_shellcontext(app)

    return app
Exemplo n.º 6
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):

    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    db.init_app(app)
    ma.init_app(app)

    api.init_app(app)
    # oidc.init_app(app)
    setup_jwt_manager(app, jwt)

    register_shellcontext(app)

    return app
Exemplo n.º 7
0
async def create_app(run_mode):
    try:
        print('CREATING APPLICATION')
        quart_app = Quart(__name__)
        quart_app.config.from_object(config.CONFIGURATION[run_mode])
        db.init_app(quart_app)
        ma.init_app(quart_app)
    except Exception as err:
        print('Error creating application in auto-analyze service: ' +
              repr(err.with_traceback(None)))
        raise

    @quart_app.after_request
    def add_version(response):
        os.getenv('OPENSHIFT_BUILD_COMMIT', '')
        return response

    register_shellcontext(quart_app)
    await quart_app.app_context().push()
    return quart_app
Exemplo n.º 8
0
async def create_app(run_mode):
    """Create the app object for configuration and use."""
    try:
        quart_app = Quart(__name__)
        quart_app.logger.debug('APPLICATION CREATED')
        quart_app.config.from_object(config.CONFIGURATION[run_mode])
        db.init_app(quart_app)
        ma.init_app(quart_app)
    except Exception as err:
        quart_app.logger.debug(
            'Error creating application in auto-analyze service: {0}'.format(
                repr(err.with_traceback(None))))
        raise

    @quart_app.after_request
    def add_version(response):  # pylint: disable=unused-variable; linter not understanding framework call
        os.getenv('OPENSHIFT_BUILD_COMMIT', '')
        return response

    register_shellcontext(quart_app)
    await quart_app.app_context().push()
    return quart_app
Exemplo n.º 9
0
from config import get_named_config  # pylint: disable=import-error
from solr_names_updater.names_processors.names import (  # noqa: I001
    process_add_to_solr as process_names_add,  # noqa: I001
    process_delete_from_solr as process_names_delete  # noqa: I001
)  # noqa: I001
from solr_names_updater.names_processors.possible_conflicts import (  # noqa: I001
    process_add_to_solr as process_possible_conflicts_add,  # noqa: I001
    process_delete_from_solr as
    process_possible_conflicts_delete  # noqa: I001, I005
)  # noqa: I001

qsm = QueueServiceManager()  # pylint: disable=invalid-name
APP_CONFIG = get_named_config(os.getenv('DEPLOYMENT_ENV', 'production'))
FLASK_APP = Flask(__name__)
FLASK_APP.config.from_object(APP_CONFIG)
db.init_app(FLASK_APP)


def is_names_event_msg_type(msg: dict):
    """Check message is of type nr state change."""
    if msg and msg.get('type', '') == 'bc.registry.names.events':
        return True

    return False


def is_processable(msg: dict):
    """Determine if message is processable using message type of msg."""
    with FLASK_APP.app_context():
        if msg and is_names_event_msg_type(msg) \
           and (nr_num := msg.get('data', {})