scout/commands/setup/setup_scout.py
def setup(context, institute, user_mail, user_name):
    """
    Setup scout instances.
    """

    context.obj['institute_name'] = institute
    context.obj['user_name'] = user_name
    context.obj['user_mail'] = user_mail

    if context.invoked_subcommand == 'demo':
        # Update context.obj settings here
        LOG.debug("Change database name to scout-demo")
        context.obj['mongodb'] = 'scout-demo'

    LOG.info("Setting database name to %s", context.obj['mongodb'])
    LOG.debug("Setting host to %s", context.obj['host'])
    LOG.debug("Setting port to %s", context.obj['port'])
    try:
        client = get_connection(
                    host=context.obj['host'],
                    port=context.obj['port'],
                    username=context.obj['username'],
                    password=context.obj['password'],
                    mongodb = context.obj['mongodb']
                )
    except ConnectionFailure:
        context.abort()

    LOG.info("connecting to database %s", context.obj['mongodb'])
    database = client[context.obj['mongodb']]
    LOG.info("Test if mongod is running")
    try:
        LOG.info("Test if mongod is running")
        database.test.find_one()
    except ServerSelectionTimeoutError as err:
        LOG.warning("Connection could not be established")
        LOG.warning("Please check if mongod is running")
        context.abort()

    LOG.info("Setting up a mongo adapter")
    mongo_adapter = MongoAdapter(database)
    context.obj['adapter'] = mongo_adapter
def setup(context, institute, user_mail, user_name):
    """
    Setup scout instances.
    """

    context.obj['institute_name'] = institute
    context.obj['user_name'] = user_name
    context.obj['user_mail'] = user_mail

    if context.invoked_subcommand == 'demo':
        # Update context.obj settings here
        LOG.debug("Change database name to scout-demo")
        context.obj['mongodb'] = 'scout-demo'

    LOG.info("Setting database name to %s", context.obj['mongodb'])
    LOG.debug("Setting host to %s", context.obj['host'])
    LOG.debug("Setting port to %s", context.obj['port'])
    try:
        client = get_connection(
                    host=context.obj['host'],
                    port=context.obj['port'],
                    username=context.obj['username'],
                    password=context.obj['password'],
                    mongodb = context.obj['mongodb']
                )
    except ConnectionFailure:
        context.abort()

    LOG.info("connecting to database %s", context.obj['mongodb'])
    database = client[context.obj['mongodb']]
    LOG.info("Test if mongod is running")
    try:
        LOG.info("Test if mongod is running")
        database.test.find_one()
    except ServerSelectionTimeoutError as err:
        LOG.warning("Connection could not be established")
        LOG.warning("Please check if mongod is running")
        context.abort()

    LOG.info("Setting up a mongo adapter")
    mongo_adapter = MongoAdapter(database)
    context.obj['adapter'] = mongo_adapter
Setup scout instances.