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


Python command.Command方法代码示例

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


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

示例1: get_parser

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def get_parser(self, prog_name):
        parser = super(CompleteCommand, self).get_parser(prog_name)
        parser.add_argument(
            "--name",
            default=None,
            metavar='<command_name>',
            help="Command name to support with command completion"
        )
        parser.add_argument(
            "--shell",
            default='bash',
            metavar='<shell>',
            choices=sorted(self._formatters.names()),
            help="Shell being used. Use none for data only (default: bash)"
        )
        return parser 
开发者ID:openstack,项目名称:cliff,代码行数:18,代码来源:complete.py

示例2: __init__

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def __init__(self,
                 app,
                 app_args,
                 wrapper: BaseFeatureLearningWrapper,
                 default_batch_size: int = 500):
        """
        Creates and initializes a new GenerateBaseCommand with the specified parameters.
        
        Parameters
        ----------
        app
            Pass through to `Command`
        app_args
            Pass through to `Command`
        wrapper: FeatureLearningWrapper
            The feature learning wrapper used for generating features
        default_batch_size: int
            Default batch size
        """
        super().__init__(app, app_args)

        self._wrapper = wrapper
        self._default_batch_size = default_batch_size 
开发者ID:auDeep,项目名称:auDeep,代码行数:25,代码来源:generate.py

示例3: __init__

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def __init__(self, **kwargs):
        self.client = None

        # Patch command.Command to add a default auth_required = True
        command.Command.auth_required = True

        # Some commands do not need authentication
        help.HelpCommand.auth_required = False
        complete.CompleteCommand.auth_required = False

        super(Barbican, self).__init__(
            description=__doc__.strip(),
            version=barbicanclient.__version__,
            command_manager=commandmanager.CommandManager(
                'openstack.key_manager.v1'),
            deferred_help=True,
            **kwargs
        ) 
开发者ID:openstack,项目名称:python-barbicanclient,代码行数:20,代码来源:barbican.py

示例4: get_header

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def get_header(self):
        return ('_' + self.escaped_name + """()
{
  local cur prev words
  COMPREPLY=()
  _get_comp_words_by_ref -n : cur prev words

  # Command data:
""") 
开发者ID:openstack,项目名称:cliff,代码行数:11,代码来源:complete.py

示例5: make_app

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def make_app(**kwargs):
    cmd_mgr = commandmanager.CommandManager('cliff.tests')

    # Register a command that succeeds
    cmd = mock.MagicMock(spec=command.Command)
    command_inst = mock.MagicMock(spec=command.Command)
    command_inst.run.return_value = 0
    cmd.return_value = command_inst
    cmd_mgr.add_command('mock', cmd)

    # Register a command that fails
    err_command = mock.Mock(name='err_command', spec=command.Command)
    err_command_inst = mock.Mock(spec=command.Command)
    err_command_inst.run = mock.Mock(
        side_effect=RuntimeError('test exception')
    )
    err_command.return_value = err_command_inst
    cmd_mgr.add_command('error', err_command)

    app = application.App('testing command hooks',
                          '1',
                          cmd_mgr,
                          stderr=mock.Mock(),  # suppress warning messages
                          **kwargs
                          )
    return app 
开发者ID:openstack,项目名称:cliff,代码行数:28,代码来源:test_command_hooks.py

示例6: make_app

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def make_app(**kwargs):
    cmd_mgr = commandmanager.CommandManager('cliff.tests')

    # Register a command that succeeds
    command = mock.MagicMock(spec=c_cmd.Command)
    command_inst = mock.MagicMock(spec=c_cmd.Command)
    command_inst.run.return_value = 0
    command.return_value = command_inst
    cmd_mgr.add_command('mock', command)

    # Register a command that fails
    err_command = mock.Mock(name='err_command', spec=c_cmd.Command)
    err_command_inst = mock.Mock(spec=c_cmd.Command)
    err_command_inst.run = mock.Mock(
        side_effect=RuntimeError('test exception')
    )
    err_command.return_value = err_command_inst
    cmd_mgr.add_command('error', err_command)

    app = application.App('testing interactive mode',
                          '1',
                          cmd_mgr,
                          stderr=mock.Mock(),  # suppress warning messages
                          **kwargs
                          )
    return app, command 
开发者ID:openstack,项目名称:cliff,代码行数:28,代码来源:test_app.py

示例7: test_option_parser_abbrev_issue

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def test_option_parser_abbrev_issue(self):
        class MyCommand(c_cmd.Command):
            def get_parser(self, prog_name):
                parser = super(MyCommand, self).get_parser(prog_name)
                parser.add_argument("--end")
                return parser

            def take_action(self, parsed_args):
                assert(parsed_args.end == '123')

        class MyCommandManager(commandmanager.CommandManager):
            def load_commands(self, namespace):
                self.add_command("mycommand", MyCommand)

        class MyApp(application.App):
            def __init__(self):
                super(MyApp, self).__init__(
                    description='testing',
                    version='0.1',
                    command_manager=MyCommandManager(None),
                )

            def build_option_parser(self, description, version):
                parser = super(MyApp, self).build_option_parser(
                    description,
                    version,
                    argparse_kwargs={'allow_abbrev': False})
                parser.add_argument('--endpoint')
                return parser

        app = MyApp()
        # NOTE(jd) --debug is necessary so assert in take_action()
        # raises correctly here
        app.run(['--debug', 'mycommand', '--end', '123']) 
开发者ID:openstack,项目名称:cliff,代码行数:36,代码来源:test_app.py

示例8: run

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def run(self, parsed_args):
        self.log.debug('run(%s)', parsed_args)
        return super(Command, self).run(parsed_args) 
开发者ID:nttcom,项目名称:eclcli,代码行数:5,代码来源:command.py

示例9: __init__

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def __init__(self):
        # Patch command.Command to add a default auth_required = True
        command.Command.auth_required = True

        # Some commands do not need authentication
        help.HelpCommand.auth_required = False
        complete.CompleteCommand.auth_required = False

        # Slight change to the meaning of --debug
        self.DEFAULT_DEBUG_VALUE = None
        self.DEFAULT_DEBUG_HELP = 'Set debug logging and traceback on errors.'

        super(ECLClient, self).__init__(
            description=__doc__.strip(),
            version=eclcli.__version__,
            command_manager=commandmanager.CommandManager('ecl.cli'),
            deferred_help=True)

        del self.command_manager.commands['complete']
        # del self.command_manager.commands['help']

        self.api_version = {}

        # Until we have command line arguments parsed, dump any stack traces
        self.dump_stack_trace = True

        # Assume TLS host certificate verification is enabled
        self.verify = True

        self.client_manager = None
        self.command_options = None

        self.do_profile = False 
开发者ID:nttcom,项目名称:eclcli,代码行数:35,代码来源:shell.py

示例10: get_parser

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def get_parser(self, prog_name):
        parser = super(SeedHypervisorHostCommandRun, self).get_parser(
            prog_name)
        group = parser.add_argument_group("Host Command Run")
        group.add_argument("--command", required=True,
                           help="Command to run (required).")
        return parser 
开发者ID:openstack,项目名称:kayobe,代码行数:9,代码来源:commands.py

示例11: __init__

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def __init__(self,
                 app,
                 app_args,
                 default_batch_size: int = 64,
                 default_num_epochs: int = 10,
                 default_learning_rate: float = 0.001,
                 default_run_name: Path = Path("./test-run")):
        """
        Create and initialize a new TrainBaseCommand with the specified parameters.
        
        Parameters
        ----------
        app
            Pass through to `Command`
        app_args
            Pass through to `Command`
        default_batch_size: int
            Default batch size
        default_num_epochs: int
            Default number of epochs
        default_learning_rate: float
            Default learning rate
        default_run_name: Path
            Default run name
        """
        super().__init__(app, app_args)

        self.default_batch_size = default_batch_size
        self.default_num_epochs = default_num_epochs
        self.default_learning_rate = default_learning_rate
        self.default_run_name = default_run_name

        self.model_filename = None
        self.record_files = None
        self.feature_shape = None
        self.num_instances = None 
开发者ID:auDeep,项目名称:auDeep,代码行数:38,代码来源:train.py

示例12: clean_up

# 需要导入模块: from cliff import command [as 别名]
# 或者: from cliff.command import Command [as 别名]
def clean_up(self, cmd, result, err):
        # type: (Command, int, Optional[Exception]) -> None

        if isinstance(err, CLIUsageError):
            self.parser.print_help() 
开发者ID:optuna,项目名称:optuna,代码行数:7,代码来源:cli.py


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