src/dirbs/cli/db.py
def cli(ctx):
    """DIRBS script to intiliaze, configure and upgrade the PostgreSQL schema."""
    config = common.ensure_config(ctx)
    db_config = config.db_config
    logger = logging.getLogger('dirbs.db')
    subcommand = ctx.invoked_subcommand

    dirbs.logging.setup_file_logging(config.log_config, 'dirbs-db_{0}_{1}'
                                     .format(subcommand, datetime.datetime.now().strftime('%Y%m%d')))

    # check subcommand should try and fail regardless of these checks.
    # install_roles subcommand installs these roles so can't do these checks
    if subcommand not in ['install_roles', 'check']:
        with utils.create_db_connection(db_config) as conn:
            try:
                utils.warn_if_db_superuser(conn)
                utils.verify_db_roles_installed(conn)
                utils.verify_db_role_for_job(conn, 'dirbs_core_power_user')
                utils.verify_db_ownership(conn)
                utils.verify_hll_schema(conn)
                if subcommand != 'install':
                    # install subcommand creates the schema, so can't check it here
                    utils.verify_core_schema(conn)
                    utils.verify_db_search_path(conn)
                if config.operational_config.activate_whitelist:
                    utils.notify_if_whitelist_activation()
            except (utils.DatabaseRoleCheckException, utils.DatabaseSchemaException) as ex:
                logger.error(str(ex))
                sys.exit(1)
DIRBS script to intiliaze, configure and upgrade the PostgreSQL schema.
DIRBS script to intiliaze, configure and upgrade the PostgreSQL schema.
DIRBS script to intiliaze configure and upgrade the PostgreSQL schema .
def cli(ctx):
    config = common.ensure_config(ctx)
    db_config = config.db_config
    logger = logging.getLogger('dirbs.db')
    subcommand = ctx.invoked_subcommand
    dirbs.logging.setup_file_logging(config.log_config, 'dirbs-db_{0}_{1}'
                                     .format(subcommand, datetime.datetime.now().strftime('%Y%m%d')))
    if subcommand not in ['install_roles', 'check']:
        with utils.create_db_connection(db_config) as conn:
            try:
                utils.warn_if_db_superuser(conn)
                utils.verify_db_roles_installed(conn)
                utils.verify_db_role_for_job(conn, 'dirbs_core_power_user')
                utils.verify_db_ownership(conn)
                utils.verify_hll_schema(conn)
                if subcommand != 'install':
                    utils.verify_core_schema(conn)
                    utils.verify_db_search_path(conn)
                if config.operational_config.activate_whitelist:
                    utils.notify_if_whitelist_activation()
            except (utils.DatabaseRoleCheckException, utils.DatabaseSchemaException) as ex:
                logger.error(str(ex))
                sys.exit(1)
def cli ( ctx ) : config = common . ensure_config ( ctx ) db_config = config . db_config logger = logging . getLogger ( 'dirbs.db' ) subcommand = ctx . invoked_subcommand dirbs . logging . setup_file_logging ( config . log_config , 'dirbs-db_{0}_{1}' . format ( subcommand , datetime . datetime . now ( ) . strftime ( '%Y%m%d' ) ) ) if subcommand not in [ 'install_roles' , 'check' ] : with utils . create_db_connection ( db_config ) as conn : try : utils . warn_if_db_superuser ( conn ) utils . verify_db_roles_installed ( conn ) utils . verify_db_role_for_job ( conn , 'dirbs_core_power_user' ) utils . verify_db_ownership ( conn ) utils . verify_hll_schema ( conn ) if subcommand != 'install' : utils . verify_core_schema ( conn ) utils . verify_db_search_path ( conn ) if config . operational_config . activate_whitelist : utils . notify_if_whitelist_activation ( ) except ( utils . DatabaseRoleCheckException , utils . DatabaseSchemaException ) as ex : logger . error ( str ( ex ) ) sys . exit ( 1 )
DIRBS script to intiliaze, configure and upgrade the PostgreSQL schema.
DIRBS script to intiliaze configure and upgrade the PostgreSQL schema .
"""DIRBS script to intiliaze, configure and upgrade the PostgreSQL schema.""" # check subcommand should try and fail regardless of these checks. # install_roles subcommand installs these roles so can't do these checks # install subcommand creates the schema, so can't check it here
ctx