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


Python cfg.SubCommandOpt方法代码示例

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


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

示例1: main

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def main():
    opt = cfg.SubCommandOpt(
        'category', title='command',
        description='kuryr-k8s-status command or category to execute',
        handler=add_parsers)

    conf = cfg.ConfigOpts()
    conf.register_cli_opt(opt)
    conf(sys.argv[1:])

    os_vif.initialize()
    objects.register_locally_defined_vifs()

    try:
        return conf.category.action_fn()
    except Exception:
        print('Error:\n%s' % traceback.format_exc())
        # This is 255 so it's not confused with the upgrade check exit codes.
        return 255 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:21,代码来源:status.py

示例2: parse_config

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def parse_config():
    DB_INIT = [
        cfg.SubCommandOpt('db',
                          dest='db',
                          title='DB Options',
                          handler=add_db_opts
                          )
    ]
    # register database backend drivers
    config.register_db_drivers_opt()
    # register database cli options
    CONF.register_cli_opts(DB_INIT)
    # register logging opts
    log.register_options(CONF)
    default_config_files = cfg.find_config_files('freezer', 'freezer-api')
    CONF(args=sys.argv[1:],
         project='freezer-api',
         default_config_files=default_config_files,
         version=FREEZER_API_VERSION
         ) 
开发者ID:openstack,项目名称:freezer-api,代码行数:22,代码来源:manage.py

示例3: main

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def main():
    command_opt = cfg.SubCommandOpt('command',
                                    title='Command',
                                    help='Available commands',
                                    handler=add_command_parsers)
    CONF.register_cli_opt(command_opt)

    CONF(project='zun')
    CONF.command.func() 
开发者ID:openstack,项目名称:zun,代码行数:11,代码来源:db_manage.py

示例4: test_run_db_manage_app

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def test_run_db_manage_app(self, m_sys, m_prepare_service):
        # Patch command function
        m_func = mock.Mock()
        cfg.CONF.register_opt(cfg.SubCommandOpt("command"))
        cfg.CONF.command.func = m_func

        # Only append if the command is not None
        m_sys.argv = list(filter(None, ["watcher-db-manage", self.command]))

        dbmanage.main()
        self.assertEqual(1, m_func.call_count)
        m_prepare_service.assert_called_once_with(
            ["watcher-db-manage", self.expected], cfg.CONF) 
开发者ID:openstack,项目名称:watcher,代码行数:15,代码来源:test_db_manage.py

示例5: main

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def main():
    command_opt = cfg.SubCommandOpt('command',
                                    title='Command',
                                    help=_('Available commands'),
                                    handler=add_command_parsers)

    CONF.register_cli_opt(command_opt)

    service.prepare_service(sys.argv)
    CONF.command.func() 
开发者ID:openstack,项目名称:cyborg,代码行数:12,代码来源:dbsync.py

示例6: list_cli_opts

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def list_cli_opts():
    return [
        cfg.SubCommandOpt(name="sub_command",
                          handler=sub_commands,
                          help=_("Available commands"),
                          title="syntribos Commands"),
        cfg.MultiStrOpt("test-types", dest="test_types", short="t",
                        default=[""], sample_default=["SQL", "XSS"],
                        help=_(
                            "Test types to run against the target API")),
        cfg.MultiStrOpt("excluded-types", dest="excluded_types", short="e",
                        default=[""], sample_default=["SQL", "XSS"],
                        help=_("Test types to be excluded from "
                               "current run against the target API")),
        cfg.BoolOpt("colorize", dest="colorize", short="cl",
                    default=True,
                    help=_("Enable color in syntribos terminal output")),
        cfg.StrOpt("outfile", short="o",
                   sample_default="out.json", help=_("File to print "
                                                     "output to")),
        cfg.StrOpt("format", dest="output_format", short="f", default="json",
                   choices=["json"], ignore_case=True,
                   help=_("The format for outputting results")),
        cfg.StrOpt("min-severity", dest="min_severity", short="S",
                   default="LOW", choices=syntribos.RANKING,
                   help=_("Select a minimum severity for reported "
                          "defects")),
        cfg.StrOpt("min-confidence", dest="min_confidence", short="C",
                   default="LOW", choices=syntribos.RANKING,
                   help=_("Select a minimum confidence for reported "
                          "defects")),
        cfg.BoolOpt("stacktrace", dest="stacktrace", default=True,
                    help=_("Select if Syntribos outputs a stacktrace "
                           " if an exception is raised")),
        cfg.StrOpt(
            "custom_root", dest="custom_root",
            help=_("Filesystem location for syntribos root directory, "
                   "containing logs, templates, payloads, config files. "
                   "Creates directories and skips interactive prompts when "
                   "used with 'syntribos init'"),
            deprecated_group="init", deprecated_name="custom_install_root")
    ] 
开发者ID:openstack-archive,项目名称:syntribos,代码行数:44,代码来源:config.py


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