当前位置: 首页>>代码示例>>Python>>正文


Python CLI.show_colors方法代码示例

本文整理汇总了Python中cli.CLI.show_colors方法的典型用法代码示例。如果您正苦于以下问题:Python CLI.show_colors方法的具体用法?Python CLI.show_colors怎么用?Python CLI.show_colors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cli.CLI的用法示例。


在下文中一共展示了CLI.show_colors方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from cli import CLI [as 别名]
# 或者: from cli.CLI import show_colors [as 别名]
def run():
    cli = CLI()
    try:
        (options, args) = cli.parse()

        if options.simple_db_migrate_version:
            msg = 'simple-db-migrate v%s' % SIMPLE_DB_MIGRATE_VERSION
            cli.info_and_exit(msg)

        if options.show_colors:
            CLI.show_colors()

        # Create config
        config = FileConfig(options.config_file, options.environment)
        config.put('schema_version', options.schema_version)
        config.put('show_sql', options.show_sql)
        config.put('show_sql_only', options.show_sql_only)
        config.put('new_migration', options.new_migration)
        config.put('drop_db_first', options.drop_db_first)
        config.put('paused_mode', options.paused_mode)
        config.put('log_dir', options.log_dir)
        config.put('label_version', options.label_version)
        config.put('force_use_files_on_down', options.force_use_files_on_down)
        config.put('force_execute_old_migrations_versions', options.force_execute_old_migrations_versions)

        # paused mode forces log_level to 2
        log_level = int(options.log_level)
        if options.paused_mode:
            log_level = 2

        config.put('log_level', log_level)

        # Ask the password for user if configured
        if config.get('db_password') == '<<ask_me>>':
            if options.password:
                passwd = options.password
            else:
                cli.msg('\nPlease inform password to connect to database "%[email protected]%s:%s"' % (config.get('db_user'), config.get('db_host'), config.get('db_name')))
                passwd = getpass()
            config.remove('db_password')
            config.put('db_password', passwd)

        # If CLI was correctly parsed, execute db-migrate.
        Main(config).execute()
    except KeyboardInterrupt:
        cli.info_and_exit("\nExecution interrupted by user...")
    except Exception, e:
        cli.error_and_exit(str(e))
开发者ID:adazzi,项目名称:simple-db-migrate,代码行数:50,代码来源:__init__.py

示例2: run

# 需要导入模块: from cli import CLI [as 别名]
# 或者: from cli.CLI import show_colors [as 别名]
def run():
    cli = CLI()
    try:
        (options, args) = cli.parse()

        if options.torneira_version:
            msg = "torneira v%s" % torneira.__version__
            cli.info_and_exit(msg)

        if options.show_colors:
            CLI.show_colors()

        Main().excecute()

    except KeyboardInterrupt:
        cli.info_and_exit("\nExecution interrupted by user...")
    except Exception, e:
        cli.error_and_exit(str(e))
开发者ID:strogo,项目名称:torneira,代码行数:20,代码来源:__init__.py

示例3: run

# 需要导入模块: from cli import CLI [as 别名]
# 或者: from cli.CLI import show_colors [as 别名]
def run():
    try:
        (options, args) = CLI().parse()

        if options.simple_db_migrate_version:
            msg = "simple-db-migrate v%s" % SIMPLE_DB_MIGRATE_VERSION
            CLI().info_and_exit(msg)

        if options.show_colors:
            CLI.show_colors()

        # Create config
        config = FileConfig(options.config_file)
        config.put("schema_version", options.schema_version)
        config.put("show_sql", options.show_sql)
        config.put("show_sql_only", options.show_sql_only)
        config.put("new_migration", options.new_migration)
        config.put("drop_db_first", options.drop_db_first)

        # If CLI was correctly parsed, execute db-migrate.
        Main(config).execute()
    except Exception, e:
        CLI().error_and_exit(str(e))
开发者ID:andrewsmedina,项目名称:simple-db-migrate,代码行数:25,代码来源:__init__.py

示例4: run

# 需要导入模块: from cli import CLI [as 别名]
# 或者: from cli.CLI import show_colors [as 别名]
def run(options):
    try:
        if options.get('simple_db_migrate_version'):
            msg = 'simple-db-migrate v%s' % SIMPLE_DB_MIGRATE_VERSION
            CLI.info_and_exit(msg)

        if options.get('show_colors'):
            CLI.show_colors()

        # Create config
        if options.get('config_file'):
            config = FileConfig(options.get('config_file'), options.get('environment'))
        else:
            config = Config()

        config.update('schema_version', options.get('schema_version'))
        config.update('show_sql', options.get('show_sql'))
        config.update('show_sql_only', options.get('show_sql_only'))
        config.update('new_migration', options.get('new_migration'))
        config.update('drop_db_first', options.get('drop_db_first'))
        config.update('paused_mode', options.get('paused_mode'))
        config.update('log_dir', options.get('log_dir'))
        config.update('label_version', options.get('label_version'))
        config.update('force_use_files_on_down', options.get('force_use_files_on_down'))
        config.update('force_execute_old_migrations_versions', options.get('force_execute_old_migrations_versions'))
        config.update('utc_timestamp', options.get('utc_timestamp'))
        config.update('database_user', options.get('database_user'))
        config.update('database_password', options.get('database_password'))
        config.update('database_host', options.get('database_host'))
        config.update('database_name', options.get('database_name'))
        if options.get('database_migrations_dir'):
            config.update("database_migrations_dir", Config._parse_migrations_dir(options.get('database_migrations_dir')))

        config.update('database_engine', options.get('database_engine'))
        if not config.get('database_engine', None):
            config.update('database_engine', "mysql")

        config.update('database_version_table', options.get('database_version_table'))
        if not config.get('database_version_table', None):
            config.update('database_version_table', "__db_version__")

        # paused mode forces log_level to 2
        log_level = int(options.get('log_level'))
        if options.get('paused_mode'):
            log_level = 2

        config.update('log_level', log_level)

        # Ask the password for user if configured
        if config.get('database_password') == '<<ask_me>>':
            if options.get('password'):
                passwd = options.get('password')
            else:
                CLI.msg('\nPlease inform password to connect to database "%[email protected]%s:%s"' % (config.get('database_user'), config.get('database_host'), config.get('database_name')))
                passwd = getpass()
            config.update('database_password', passwd)

        # If CLI was correctly parsed, execute db-migrate.
        Main(config).execute()
    except KeyboardInterrupt:
        CLI.info_and_exit("\nExecution interrupted by user...")
    except Exception, e:
        CLI.error_and_exit(str(e))
开发者ID:gustavosoares,项目名称:simple-db-migrate,代码行数:65,代码来源:__init__.py

示例5: run

# 需要导入模块: from cli import CLI [as 别名]
# 或者: from cli.CLI import show_colors [as 别名]
def run(options):
    """ Initial Module. Treat Parameters and call Main Module for execution """
    try:
        if options.get('simple_virtuoso_migrate_version'):
            msg = ('simple-virtuoso-migrate v%s' %
                                            SIMPLE_VIRTUOSO_MIGRATE_VERSION)
            CLI.info_and_exit(msg)

        if options.get('show_colors'):
            CLI.show_colors()

        # Create config
        if options.get('config_file'):
            config = FileConfig(options.get('config_file'),
                                options.get('environment'))
        else:
            config = Config()

        config.update('schema_version', options.get('schema_version'))
        config.update('show_sparql', options.get('show_sparql'))
        config.update('show_sparql_only', options.get('show_sparql_only'))
        config.update('file_migration', options.get('file_migration'))
        #config.update('add_ttl', options.get('add_ttl'))
        config.update('load_ttl', options.get('load_ttl'))
        config.update('log_dir', options.get('log_dir'))
        config.update('database_user', options.get('database_user'))
        config.update('database_password', options.get('database_password'))
        config.update('host_user', options.get('host_user'))
        config.update('host_password', options.get('host_password'))
        config.update('virtuoso_dirs_allowed',
                      options.get('virtuoso_dirs_allowed'))
        config.update('database_host', options.get('database_host'))
        config.update('database_port', options.get('database_port'))
        config.update('database_endpoint', options.get('database_endpoint'))
        config.update('database_graph', options.get('database_graph'))
        config.update('database_ontology', options.get('database_ontology'))
        if options.get('database_migrations_dir'):
            config.update("database_migrations_dir",
                          Config._parse_migrations_dir(
                                            options.get(
                                                'database_migrations_dir')))

        config.update("database_migrations_dir",
                      config.get("database_migrations_dir")[0])
        config.update('log_level', int(options.get('log_level')))

        # Ask the password for user if configured
        if config.get('database_password') == '<<ask_me>>':
            CLI.msg('\nPlease inform password to connect to virtuoso (DATABASE) "%[email protected]%s"' % (config.get('database_user'),
                                                config.get('database_host')))
            passwd = getpass()
            config.update('database_password', passwd)

        is_local = config.get('database_host', '').lower() in ["localhost",
                                                               "127.0.0.1"]
        if config.get('load_ttl') and\
                config.get('virtuoso_dirs_allowed') is None and\
                not is_local:
            if config.get('host_password') == '<<ask_me>>':
                msg = '\nPlease inform password to connect to virtuoso (HOST) "%[email protected]%s"'
                CLI.msg(msg % (config.get('host_user'),
                               config.get('database_host')))
                passwd = getpass()
                config.update('host_password', passwd)
        # If CLI was correctly parsed, execute db-virtuoso.
        Main(config).execute()
    except KeyboardInterrupt:
        CLI.info_and_exit("\nExecution interrupted by user...")
    except Exception, e:
        CLI.error_and_exit(unicode(e))
开发者ID:viniciuschagas,项目名称:simple-virtuoso-migrate,代码行数:72,代码来源:run.py

示例6: run

# 需要导入模块: from cli import CLI [as 别名]
# 或者: from cli.CLI import show_colors [as 别名]
def run(options):
    """ Initial Module. Treat Parameters and call Main Module for execution """
    try:
        if options.get("simple_virtuoso_migrate_version"):
            msg = "simple-virtuoso-migrate v%s" % SIMPLE_VIRTUOSO_MIGRATE_VERSION
            CLI.info_and_exit(msg)

        if options.get("show_colors"):
            CLI.show_colors()

        # Create config
        if options.get("config_file"):
            config = FileConfig(options.get("config_file"), options.get("environment"))
        else:
            config = Config()

        config.update("schema_version", options.get("schema_version"))
        config.update("show_sparql", options.get("show_sparql"))
        config.update("show_sparql_only", options.get("show_sparql_only"))
        config.update("file_migration", options.get("file_migration"))
        # config.update('add_ttl', options.get('add_ttl'))
        config.update("load_ttl", options.get("load_ttl"))
        config.update("log_dir", options.get("log_dir"))
        config.update("database_user", options.get("database_user"))
        config.update("database_password", options.get("database_password"))
        config.update("host_user", options.get("host_user"))
        config.update("host_password", options.get("host_password"))
        config.update("virtuoso_dirs_allowed", options.get("virtuoso_dirs_allowed"))
        config.update("database_host", options.get("database_host"))
        config.update("database_port", options.get("database_port"))
        config.update("database_endpoint", options.get("database_endpoint"))
        config.update("database_graph", options.get("database_graph"))
        config.update("database_ontology", options.get("database_ontology"))
        if options.get("database_migrations_dir"):
            config.update(
                "database_migrations_dir", Config._parse_migrations_dir(options.get("database_migrations_dir"))
            )

        config.update("database_migrations_dir", config.get("database_migrations_dir")[0])
        config.update("log_level", int(options.get("log_level")))

        # Ask the password for user if configured
        if config.get("database_password") == "<<ask_me>>":
            CLI.msg(
                '\nPlease inform password to connect to\
                virtuoso (DATABASE) "%[email protected]%s"'
                % (config.get("database_user"), config.get("database_host"))
            )
            passwd = getpass()
            config.update("database_password", passwd)

        is_local = config.get("database_host", "").lower() in ["localhost", "127.0.0.1"]
        # import pdb; pdb.set_trace()
        if config.get("load_ttl") and config.get("virtuoso_dirs_allowed") is None and not is_local:
            if config.get("host_password") == "<<ask_me>>":
                CLI.msg(
                    '\nPlease inform password to connect to\
                virtuoso (HOST) "%[email protected]%s"'
                    % (config.get("host_user"), config.get("database_host"))
                )
                passwd = getpass()
                config.update("host_password", passwd)
        # If CLI was correctly parsed, execute db-virtuoso.
        Main(config).execute()
    except KeyboardInterrupt:
        CLI.info_and_exit("\nExecution interrupted by user...")
    except Exception, e:
        CLI.error_and_exit(unicode(e))
开发者ID:tiofree,项目名称:simple-virtuoso-migrate,代码行数:70,代码来源:run.py


注:本文中的cli.CLI.show_colors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。