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