當前位置: 首頁>>代碼示例>>Python>>正文


Python command.Command方法代碼示例

本文整理匯總了Python中osc_lib.command.command.Command方法的典型用法代碼示例。如果您正苦於以下問題:Python command.Command方法的具體用法?Python command.Command怎麽用?Python command.Command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在osc_lib.command.command的用法示例。


在下文中一共展示了command.Command方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_command_class

# 需要導入模塊: from osc_lib.command import command [as 別名]
# 或者: from osc_lib.command.command import Command [as 別名]
def create_command_class(name, func_module):
    """Dynamically creates subclass of MigratingCommand.

    Method takes name of the function, module it is part of
    and builds the subclass of :py:class:`MigratingCommand`.
    Having a subclass of :py:class:`cliff.command.Command` is mandatory
    for the osc-lib integration.

    :param name: name of the function
    :type name: basestring
    :param func_module: the module function is part of
    :type func_module: module
    :return: command name, subclass of :py:class:`MigratingCommand`
    :rtype: tuple(basestring, class)

    """

    cmd_name = name[3:].replace('_', '-')
    callback = getattr(func_module, name)
    desc = callback.__doc__ or ''
    help = desc.strip().split('\n')[0]

    arguments = getattr(callback, 'arguments', [])

    body = {
        '_args': arguments,
        '_callback': staticmethod(callback),
        '_description': desc,
        '_epilog': desc,
        '_help': help
    }

    claz = type('%sCommand' % cmd_name.title().replace('-', ''),
                (MigratingCommand,), body)

    return cmd_name, claz 
開發者ID:openstack,項目名稱:python-monascaclient,代碼行數:38,代碼來源:migration.py

示例2: run

# 需要導入模塊: from osc_lib.command import command [as 別名]
# 或者: from osc_lib.command.command import Command [as 別名]
def run(self, parsed_args):
        utils.store_cli_param(self.cmd_name, parsed_args)
        try:
            super(Command, self).run(parsed_args)
        except (oscexc.CommandError, exceptions.Base):
            raise
        except Exception:
            self.log.exception("Exception occured while running the command")
            raise 
開發者ID:openstack,項目名稱:python-tripleoclient,代碼行數:11,代碼來源:command.py


注:本文中的osc_lib.command.command.Command方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。