python cmd第3个子级别没有退出

时间:2013-03-15 19:43:31

标签: python

我正在处理此收件人的一些代码http://code.activestate.com/recipes/280500/
我从github用户jochem代码获得的EPP代码(仅导入):Python-EPP(只是要清楚,我没有自己创建EPP代码)

我添加了

def do_A_register(self, args):
    i = A_register()
    i.cmdloop()

引导我: (编辑:格式化搞砸了)

class A_register(cmd.Cmd):
   prompt = "(A register) "
   def do_handles(self, args):
       # Goto sub command
       i = A_registerHandles()
       i.prompt = self.prompt[:-1]+'-> handles $ '
       i.cmdloop()

   def do_domain(self, args):
       # Goto sub command
       pass

   def do_exit(self, args):
       return True

   def do_EOF(self, args):
       return self.do_exit(args)

如果我在这个子菜单中退出或crtl-D,我会返回1级,这是我想要的但是如果我升级到1级(第2级)我不能回到1级(其中0级是壳)

第3级代码是这个

class A_registerHandles(cmd.Cmd):
config = {
    'host': 'epp.a_registar.com',
    'port': 700,
    'user': '<username>',
    'pass': '<password>',
    'handle': '<defaultHandle>',
}

def do_handleAvailable(self, args):
    print "Give handle:",
    handle = raw_input().strip()
    self.epp = EPP(**self.config)
    self.contact = Contact(self.epp, handle)
    canCreate = self.contact.available()
    if bool(canCreate):
        print "Handle %s is free to use." % handle
    else:
        print "Handle %s is in use!" % handle

def do_handleInfo(self, args):
    print "Give handle: ",
    handle = raw_input().strip()
    self.epp = EPP(**self.config)
    self.contact = Contact(self.epp, handle)
    handleInfo = self.contact.info()

def do_exit(self, args):
    return True

def do_EOF(self, args):
    return self.do_exit(args)

所以我想知道如何从第2级返回到第1级(或第3级到第2级或第4级到第3级,你抓住我的漂移)

我创建了一个工作示例,它从2级返回到1级但不是3到2级。 由于长度我将代码添加到pastebin http://pastebin.com/qjF4LPXZ

我正在运行的python版本:

  

Python 2.7.3(默认,2012年9月26日,21:51:14)   linux2上的[GCC 4.7.2]

Thnx的任何回复。 保罗。

0 个答案:

没有答案