當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。