예제 #1
0
def _mongo_import_bson(db_name, collection, bson_file):
    call(["mongorestore",
          "--host", evg.get_required_variable('MONGO_PORT_27017_TCP_ADDR'),
          "--port", evg.get_required_variable('MONGO_PORT_27017_TCP_ADDR'),
          "--db", db_name,
          "--collection", collection,
          str(bson_file)
          ])
예제 #2
0
def init_app(app, db_instance, extra_config_settings={}):
    _init_app_config_settings(app, extra_config_settings)

    # Setup Flask-Mail
    mail = Mail(app)

    babel = Babel(app)

    # Setup Flask-User to handle user account related forms
    from webrob.models.users import User
    db_adapter = SQLAlchemyAdapter(db_instance, User)
    app.user_manager = UserManager(db_adapter,
                                   app)  # Init Flask-User and bind to app

    # Load all models.py files to register db.Models with SQLAlchemy
    # Needs to remain in code, even if IDEs might show it's unused, Flask will use them during runtime
    from webrob.models import users
    from webrob.models import tutorials
    from webrob.models import teaching
    from webrob.models import experiments

    # Load all views.py files to register @app.routes() with Flask
    # Needs to remain in code, even if IDEs might show it's unused, Flask will use them during runtime
    from webrob.pages import api
    from webrob.pages import db
    from webrob.pages import editor
    from webrob.pages import experiments
    from webrob.pages import knowrob
    from webrob.pages import login
    from webrob.pages import meshes
    from webrob.pages import mongo
    from webrob.pages import tutorials
    from webrob.pages import oauth

    init_db(app, db_instance)
    init_webapp(app, db_instance)

    add_user(app=app,
             db=db_instance,
             user_manager=app.user_manager,
             name='admin',
             mail=evg.get_variable_with_default('OPENEASE_MAIL_USERNAME',
                                                '*****@*****.**'),
             pw=evg.get_required_variable('OPENEASE_ADMIN_PASSWORD'),
             roles=['admin'])

    _log_webapp_started(app)
    return app
예제 #3
0
 def _retrieve_sqlalchemy_db_uri():
     Config.SQLALCHEMY_DATABASE_URI = 'postgresql://docker@' + \
                                      evg.get_required_variable('POSTGRES_PORT_5432_TCP_ADDR') + ':' + \
                                      evg.get_required_variable('POSTGRES_PORT_5432_TCP_PORT') + '/docker'
예제 #4
0
 def _init_http_client():
     Config.HTTP_CLIENT = pyjsonrpc.HttpClient(
         url="http://" +
         evg.get_required_variable('DOCKERBRIDGE_PORT_5001_TCP_ADDR') +
         ':' + evg.get_required_variable('DOCKERBRIDGE_PORT_5001_TCP_PORT'))
예제 #5
0
 def _retrieve_mail_password():
     Config.MAIL_PASSWORD = evg.get_required_variable(
         'OPENEASE_MAIL_PASSWORD')
def test_required_variable_exception():
    with pytest.raises(KeyError, match=ENVIRONMENT_VARIABLE_NAME):
        get_required_variable(ENVIRONMENT_VARIABLE_NAME)
def test_successfully_get_required_variable(monkeypatch):
    monkeypatch.setitem(os.environ, ENVIRONMENT_VARIABLE_NAME,
                        ENVIRONMENT_VARIABLE_VALUE)
    assert get_required_variable(
        ENVIRONMENT_VARIABLE_NAME) == ENVIRONMENT_VARIABLE_VALUE
예제 #8
0
def _connect_to_mongo_db():
    host = evg.get_required_variable('MONGO_PORT_27017_TCP_ADDR')
    port = evg.get_required_variable('MONGO_PORT_27017_TCP_PORT')
    return MongoClient(host, int(port))