Exemplo n.º 1
0
def check(config_file):
    """
    Verify & view current configuration
    """
    echo('Version:\t' + style(str(datacube.__version__), bold=True))
    echo('Config files:\t' +
         style(','.join(config_file.files_loaded), bold=True))
    echo('Host:\t\t' + style('{}:{}'.format(
        config_file.db_hostname or 'localhost', config_file.db_port or '5432'),
                             bold=True))
    echo('Database:\t' +
         style('{}'.format(config_file.db_database), bold=True))
    echo('User:\t\t' + style('{}'.format(config_file.db_username), bold=True))

    echo()
    echo('Valid connection:\t', nl=False)
    try:
        # Initialise driver manager singleton
        index = DriverManager(default_driver_name=None,
                              index=None,
                              local_config=config_file).index
        echo(style('YES', bold=True))
        for role, user, description in index.users.list_users():
            if user == config_file.db_username:
                echo('You have %s privileges.' %
                     style(role.upper(), bold=True))
    except OperationalError as e:
        handle_exception('Error Connecting to Database: %s', e)
    except IndexSetupError as e:
        handle_exception('Database not initialised: %s', e)
Exemplo n.º 2
0
def check(local_config: LocalConfig):
    """
    Verify & view current configuration
    """
    def echo_field(name, value):
        echo('{:<15}'.format(name + ':') + style(str(value), bold=True))

    echo_field('Version', datacube.__version__)
    echo_field('Config files', ','.join(local_config.files_loaded))
    echo_field(
        'Host', '{}:{}'.format(local_config['db_hostname'] or 'localhost',
                               local_config.get('db_port', None) or '5432'))

    echo_field('Database', local_config['db_database'])
    echo_field('User', local_config['db_username'])
    echo_field('Environment', local_config['env'])
    echo_field('Index Driver', local_config['index_driver'])

    echo()
    echo('Valid connection:\t', nl=False)
    try:
        index = index_connect(local_config=local_config)
        echo(style('YES', bold=True))
        for role, user, description in index.users.list_users():
            if user == local_config['db_username']:
                echo('You have %s privileges.' %
                     style(role.upper(), bold=True))
    except OperationalError as e:
        handle_exception('Error Connecting to Database: %s', e)
    except IndexSetupError as e:
        handle_exception('Database not initialised: %s', e)
Exemplo n.º 3
0
def check(config_file):
    """
    Verify & view current configuration
    """
    echo('Read configurations files from: %s' % config_file.files_loaded)
    echo('Host: {}:{}'.format(config_file.db_hostname or 'localhost', config_file.db_port or '5432'))
    echo('Database: {}'.format(config_file.db_database))
    echo('User: {}'.format(config_file.db_username))

    echo('\n')
    echo('Attempting connect')
    try:
        index_connect(local_config=config_file)
        echo('Success.')
    except OperationalError as e:
        handle_exception('Error Connecting to Database: %s', e)
    except IndexSetupError as e:
        handle_exception('Database not initialised: %s', e)
Exemplo n.º 4
0
def check(config_file):
    """
    Verify & view current configuration
    """
    echo('Read configurations files from: %s' % config_file.files_loaded)
    echo('Host: {}:{}'.format(config_file.db_hostname or 'localhost',
                              config_file.db_port or '5432'))
    echo('Database: {}'.format(config_file.db_database))
    echo('User: {}'.format(config_file.db_username))

    echo('\n')
    echo('Attempting connect')
    try:
        index_connect(local_config=config_file)
        echo('Success.')
    except OperationalError as e:
        handle_exception('Error Connecting to Database: %s', e)
    except IndexSetupError as e:
        handle_exception('Database not initialised: %s', e)
Exemplo n.º 5
0
def check(config_file):
    """
    Verify & view current configuration
    """
    echo('Version: %s' % datacube.__version__)
    echo('Read configurations files from: %s' % config_file.files_loaded)
    echo('Host: {}:{}'.format(config_file.db_hostname or 'localhost', config_file.db_port or '5432'))
    echo('Database: {}'.format(config_file.db_database))
    echo('User: {}'.format(config_file.db_username))

    echo('\n')
    echo('Attempting connect')
    try:
        index = index_connect(local_config=config_file)
        echo('Success.')
        for role, user, description in index.users.list_users():
            if user == config_file.db_username:
                echo('You have %s privileges.' % role.upper())
    except OperationalError as e:
        handle_exception('Error Connecting to Database: %s', e)
    except IndexSetupError as e:
        handle_exception('Database not initialised: %s', e)
Exemplo n.º 6
0
def check(config_file):
    """
    Verify & view current configuration
    """
    echo('Version: %s' % datacube.__version__)
    echo('Read configurations files from: %s' % config_file.files_loaded)
    echo('Host: {}:{}'.format(config_file.db_hostname or 'localhost', config_file.db_port or '5432'))
    echo('Database: {}'.format(config_file.db_database))
    echo('User: {}'.format(config_file.db_username))

    echo('\n')
    echo('Attempting connect')
    try:
        index = index_connect(local_config=config_file)
        echo('Success.')
        for role, user, description in index.users.list_users():
            if user == config_file.db_username:
                echo('You have %s privileges.' % role.upper())
    except OperationalError as e:
        handle_exception('Error Connecting to Database: %s', e)
    except IndexSetupError as e:
        handle_exception('Database not initialised: %s', e)