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


Python cmd2.Cmd类代码示例

本文整理汇总了Python中cmd2.Cmd的典型用法代码示例。如果您正苦于以下问题:Python Cmd类的具体用法?Python Cmd怎么用?Python Cmd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__(self):
     Cmd.__init__(self)
     mixins.bootstrap.BootstrapMixin.__init__(self)
     self._load_config()
     if 'url' in self.config and self.config['url']:
         self._init_stacks()
     self._validate_auth()
开发者ID:drdancain,项目名称:stackdio-python-client,代码行数:7,代码来源:__init__.py

示例2: __init__

    def __init__(self, verbose=False):
        Cmd.__init__(self)

        self.pp = pprint.PrettyPrinter(indent=4)

        try:
            self.conn = boto.connect_dynamodb()
        except Exception as e:
            self.conn = None
            print e
            print "Cannot connect to dynamodb - Check your credentials in ~/.boto or use the 'login' command"

        # by default readline thinks - and other characters are word delimiters :(
        if readline:
            readline.set_completer_delims(re.sub('[-~]', '', readline.get_completer_delims()))

            path = os.path.join(os.environ.get('HOME', ''), HISTORY_FILE)
            self.history_file = os.path.abspath(path)
        else:
            self.history_file = None

        self.tables = []
        self.table = None
        self.consistent = False
        self.consumed = False
        self.verbose = verbose
        self.next_key = None
        self.schema = {}

        if verbose:
            self._onchange_verbose(None, verbose)
开发者ID:raff,项目名称:dynash,代码行数:31,代码来源:dynash.py

示例3: __init__

 def __init__(self):
     Cmd.__init__(self)
     try:
         import readline
         readline.set_completer_delims(' \t\n"') # initially it was ' \t\n`[email protected]#$^&*()=+[{]}\\|;:\'",<>?', but I dont want to break on too many
     except:
         pass
开发者ID:fqj1994,项目名称:dupan,代码行数:7,代码来源:dupan.py

示例4: __init__

	def __init__(self, namefile):
		Cmd.__init__(self)
		self.last = []
		self.last.append([])
		self.prompt = bcolors.PROMPT + "ForPCAP >>> " + bcolors.ENDC
		self.loadPcap(namefile)
		self.cmd = ""
开发者ID:bl4ckic3,项目名称:ForensicPCAP,代码行数:7,代码来源:forensicPCAP.py

示例5: __init__

 def __init__(self, logical_device_id, get_stub):
     Cmd.__init__(self)
     self.get_stub = get_stub
     self.logical_device_id = logical_device_id
     self.prompt = '(' + self.colorize(
         self.colorize('logical device {}'.format(logical_device_id), 'red'),
         'bold') + ') '
开发者ID:gcgirish-radisys,项目名称:voltha,代码行数:7,代码来源:logical_device.py

示例6: do_help

 def do_help(self, arg):
     """Command to display help info"""
     self.stdout.write("\n%s Namespace Help\n" % self.namespace)
     
     # If we're just in the cmd2 namespace, return its help
     if (self.namespace == 'cmd2'):
         Cmd.do_help(arg)
         return
     else:  # Else, if we're in another namespace, try the following:
         if arg: # If getting help for a specific command in the namespace, try:
             # First see if the namespace command exists
             try:
                 do_func = getattr(self, 'do_' + self.namespace + "_" + arg)
             except AttributeError:
                 # Namespace function doesn't exist - see if there is a non-namespace / cmd2 command with arg name
                 try:
                     do_func = getattr(self, 'do_' + arg)
                     Cmd.do_help(arg)
                     return
                 except AttributeError:
                     self.stdout.write("[ERROR] Command does not exist in this or top-level namespace: %s\n" % arg)
                     return
             try:
                 # Next see if there is a help_<namespace>_<command> method is available to call
                 help_func = getattr(self, 'help_' + self.namespace + '_' + arg)
                 help_func()
                 return
             except AttributeError:
                 # If no help method for the command, get the __doc__ for the method if exists
                 try:
                     doc=getattr(self, 'do_' + self.namespace + '_' + arg).__doc__
                     if doc:
                         self.stdout.write("%s\n" % str(doc))
                         return
                 except AttributeError:
                     self.stdout.write("%s\n"%str(self.nohelp % (arg,)))
                     return
         # Otherwise display generic help
         else:
             #names = self.get_names() + self.get_names_addendum
             names = self.get_names()
             cmds_doc = []
             cmds_undoc = []
             cmds_cmd2_namespace = []
             for name in names:
                 if name.startswith('do_' + self.namespace):
                     cmd_prefix_length = len(self.namespace)+4
                     cmd=name[cmd_prefix_length:]
                     if getattr(self, name).__doc__:
                         cmds_doc.append(cmd)
                     else:
                         cmds_undoc.append(cmd)
                 elif name[:3] == 'do_':
                     cmd=name[3:]
                     cmds_cmd2_namespace.append(cmd)
             self.stdout.write("%s\n" % str(self.doc_leader))
             self.print_topics(self.doc_header,   cmds_doc,   15,80)
             self.print_topics(self.undoc_header, cmds_undoc, 15,80)
             self.print_topics("'cmd2' Namespace Commands", cmds_cmd2_namespace, 15, 80)
开发者ID:ZionOps,项目名称:poortego,代码行数:59,代码来源:cmd2_interface.py

示例7: __init__

 def __init__(self, session_obj):
     Cmd.__init__(self)
     self.my_session = session_obj
     self.supported_namespaces = ['poortego', 'cmd2']
     self.namespace = 'poortego'
     self.no_namespace_commands = ['help', 'welcome', 'namespace', 'exit']
     self.get_names_addendum = [] # list of additional class methods not returned from python dir() at runtime
     self.prompt = self.my_session.my_conf.conf_settings['poortego_prompt'] + ' '
开发者ID:ZionOps,项目名称:poortego,代码行数:8,代码来源:cmd2_interface.py

示例8: __init__

 def __init__(self, *args, **kwargs):
     self.user = kwargs.pop("user")
     self.username = kwargs.pop("username")
     self.passwd = kwargs.pop("passwd")
     self.api_auth = HTTPBasicAuth(self.username, self.passwd)
     self.site = Site.objects.get_current()
     self.prompt = "Schemanizer(%s)> " % (self.username)
     Cmd.__init__(self, *args, **kwargs)
开发者ID:killkill,项目名称:schemanizer,代码行数:8,代码来源:signin.py

示例9: __init__

 def __init__(self, device_id, get_stub):
     Cmd.__init__(self)
     self.get_stub = get_stub
     self.device_id = device_id
     self.prompt = '(' + self.colorize(
         self.colorize('device {}'.format(device_id), 'red'), 'bold') + ') '
     self.pm_config_last = None
     self.pm_config_dirty = False
开发者ID:gcgirish-radisys,项目名称:voltha,代码行数:8,代码来源:device.py

示例10: __init__

 def __init__(self, parent):
     Cmd.__init__(self)
     self.parent = parent
     self.prompt = self.parent.prompt[:-2] + "find:: "
     self.machines = []
     self.project = ""
     self.locdata_dirs = []
     self.project_dirs = []
     self.record = self.parent.record
开发者ID:gjcoombes,项目名称:jack,代码行数:9,代码来源:jack.py

示例11: __init__

    def __init__(self):
        Cmd.__init__(self)
        self.cli_parser = argparse.ArgumentParser()

        subparsers = self.cli_parser.add_subparsers(help='internal commands')

        publish_parser = subparsers.add_parser('publish', help='publish')
        publish_parser.add_argument('--to', dest="to", metavar='PATH', type=str,
                                    help='acoustic model directory', required=True)
开发者ID:aurelienmaury,项目名称:zero-console,代码行数:9,代码来源:zero-console.py

示例12: __init__

 def __init__(self, **kwargs):
     Cmd.__init__(self, **kwargs)
     self.prompt = 'BES> '
     #self.do_conf(None)
     
     self.BES_ROOT_SERVER = None
     self.BES_USER_NAME = None
     self.BES_PASSWORD = None
     self.bes_conn = None
开发者ID:CLCMacTeam,项目名称:besapi,代码行数:9,代码来源:bescli.py

示例13: __init__

    def __init__(self):
        package = kolala.actions
        for loader, name, is_pkg in pkgutil.walk_packages(package.__path__):
            module = loader.find_module(name).load_module(name)
            if getattr(module, 'main', None) is not None:
                setattr(self, 'do_' + name, module.main)
            if getattr(module, 'help', None) is not None:
                setattr(self, 'help_' + name, module.help)

        Cmd.__init__(self)
开发者ID:mapledyne,项目名称:kolala,代码行数:10,代码来源:KoLCmd.py

示例14: cmdloop

 def cmdloop(self):
     try:
         Cmd.cmdloop(self)
     except KeyboardInterrupt as e:
         self.__key_interrupt = self.__key_interrupt + 1
         if self.__key_interrupt > 1:
             print('^C')
             self.do_exit(self)
         else:
             print('Press Ctrl-C again to exit.')
             self.cmdloop()
开发者ID:TamirAl,项目名称:pidgey,代码行数:11,代码来源:pidgey.py

示例15: __init__

    def __init__(self, port, debug):
        Cmd.__init__(self)

        if readline:
            path = os.path.join(os.environ.get('HOME', ''), HISTORY_FILE)
            self.history_file = os.path.abspath(path)
        else:
            self.history_file = None

        self.debug = debug
        self.port = port
        self.init_search()
开发者ID:RomanShestakov,项目名称:elseql,代码行数:12,代码来源:elseql.py


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