scout/commands/base.py
def cli(context, mongodb, username, password, authdb, host, port, loglevel, config, demo):
    """scout: manage interactions with a scout instance."""
    # log_format = "%(message)s" if sys.stdout.isatty() else None
    log_format = None
    coloredlogs.install(level=loglevel, fmt=log_format)
    LOG.info("Running scout version %s", __version__)
    LOG.debug("Debug logging enabled.")

    mongo_config = {}
    cli_config = {}
    if config:
        LOG.debug("Use config file %s", config)
        with open(config, 'r') as in_handle:
            cli_config = yaml.load(in_handle)

    mongo_config['mongodb'] = (mongodb or cli_config.get('mongodb') or 'scout')
    if demo:
        mongo_config['mongodb'] = 'scout-demo'

    mongo_config['host'] = (host or cli_config.get('host') or 'localhost')
    mongo_config['port'] = (port or cli_config.get('port') or 27017)
    mongo_config['username'] = username or cli_config.get('username')
    mongo_config['password'] = password or cli_config.get('password')
    mongo_config['authdb'] = authdb or cli_config.get('authdb') or mongo_config['mongodb']
    mongo_config['omim_api_key'] = cli_config.get('omim_api_key')

    if context.invoked_subcommand in ('setup', 'serve'):
        mongo_config['adapter'] = None
    else:
        LOG.info("Setting database name to %s", mongo_config['mongodb'])
        LOG.debug("Setting host to %s", mongo_config['host'])
        LOG.debug("Setting port to %s", mongo_config['port'])

        try:
            client = get_connection(**mongo_config)
        except ConnectionFailure:
            context.abort()

        database = client[mongo_config['mongodb']]

        LOG.info("Setting up a mongo adapter")
        mongo_config['client'] = client
        adapter = MongoAdapter(database)
        mongo_config['adapter'] = adapter
        
        LOG.info("Check if authenticated...")
        try:
            for ins_obj in adapter.institutes():
                pass
        except OperationFailure as err:
            LOG.info("User not authenticated")
            context.abort()
        

    context.obj = mongo_config
def cli(context, mongodb, username, password, authdb, host, port, loglevel, config, demo):
    """scout: manage interactions with a scout instance."""
    # log_format = "%(message)s" if sys.stdout.isatty() else None
    log_format = None
    coloredlogs.install(level=loglevel, fmt=log_format)
    LOG.info("Running scout version %s", __version__)
    LOG.debug("Debug logging enabled.")

    mongo_config = {}
    cli_config = {}
    if config:
        LOG.debug("Use config file %s", config)
        with open(config, 'r') as in_handle:
            cli_config = yaml.load(in_handle)

    mongo_config['mongodb'] = (mongodb or cli_config.get('mongodb') or 'scout')
    if demo:
        mongo_config['mongodb'] = 'scout-demo'

    mongo_config['host'] = (host or cli_config.get('host') or 'localhost')
    mongo_config['port'] = (port or cli_config.get('port') or 27017)
    mongo_config['username'] = username or cli_config.get('username')
    mongo_config['password'] = password or cli_config.get('password')
    mongo_config['authdb'] = authdb or cli_config.get('authdb') or mongo_config['mongodb']
    mongo_config['omim_api_key'] = cli_config.get('omim_api_key')

    if context.invoked_subcommand in ('setup', 'serve'):
        mongo_config['adapter'] = None
    else:
        LOG.info("Setting database name to %s", mongo_config['mongodb'])
        LOG.debug("Setting host to %s", mongo_config['host'])
        LOG.debug("Setting port to %s", mongo_config['port'])

        try:
            client = get_connection(**mongo_config)
        except ConnectionFailure:
            context.abort()

        database = client[mongo_config['mongodb']]

        LOG.info("Setting up a mongo adapter")
        mongo_config['client'] = client
        adapter = MongoAdapter(database)
        mongo_config['adapter'] = adapter
        
        LOG.info("Check if authenticated...")
        try:
            for ins_obj in adapter.institutes():
                pass
        except OperationFailure as err:
            LOG.info("User not authenticated")
            context.abort()
        

    context.obj = mongo_config
def cli ( context , mongodb , username , password , authdb , host , port , loglevel , config , demo ) : # log_format = "%(message)s" if sys.stdout.isatty() else None log_format = None coloredlogs . install ( level = loglevel , fmt = log_format ) LOG . info ( "Running scout version %s" , __version__ ) LOG . debug ( "Debug logging enabled." ) mongo_config = { } cli_config = { } if config : LOG . debug ( "Use config file %s" , config ) with open ( config , 'r' ) as in_handle : cli_config = yaml . load ( in_handle ) mongo_config [ 'mongodb' ] = ( mongodb or cli_config . get ( 'mongodb' ) or 'scout' ) if demo : mongo_config [ 'mongodb' ] = 'scout-demo' mongo_config [ 'host' ] = ( host or cli_config . get ( 'host' ) or 'localhost' ) mongo_config [ 'port' ] = ( port or cli_config . get ( 'port' ) or 27017 ) mongo_config [ 'username' ] = username or cli_config . get ( 'username' ) mongo_config [ 'password' ] = password or cli_config . get ( 'password' ) mongo_config [ 'authdb' ] = authdb or cli_config . get ( 'authdb' ) or mongo_config [ 'mongodb' ] mongo_config [ 'omim_api_key' ] = cli_config . get ( 'omim_api_key' ) if context . invoked_subcommand in ( 'setup' , 'serve' ) : mongo_config [ 'adapter' ] = None else : LOG . info ( "Setting database name to %s" , mongo_config [ 'mongodb' ] ) LOG . debug ( "Setting host to %s" , mongo_config [ 'host' ] ) LOG . debug ( "Setting port to %s" , mongo_config [ 'port' ] ) try : client = get_connection ( * * mongo_config ) except ConnectionFailure : context . abort ( ) database = client [ mongo_config [ 'mongodb' ] ] LOG . info ( "Setting up a mongo adapter" ) mongo_config [ 'client' ] = client adapter = MongoAdapter ( database ) mongo_config [ 'adapter' ] = adapter LOG . info ( "Check if authenticated..." ) try : for ins_obj in adapter . institutes ( ) : pass except OperationFailure as err : LOG . info ( "User not authenticated" ) context . abort ( ) context . obj = mongo_config
scout: manage interactions with a scout instance.
scout : manage interactions with a scout instance .