add queued commands to subcommands
@@ -19,10 +19,11 @@ from poseidon.helpers.exception_decor import exception
class ShowInterpreter(cmd.Cmd):
- def __init__(self, file=None, prompt=''):
+ def __init__(self, file=None, prompt='', cmdqueue=[]):
cmd.Cmd.__init__(self)
self.file = file
self.prompt = prompt + '(show) '
+ self.cmdqueue = cmdqueue
def do_all(self, args):
'ALL HELP'
@@ -30,6 +31,7 @@ class ShowInterpreter(cmd.Cmd):
@exception
def do_eof(self, arg):
+ self.close()
return True
def precmd(self, line):
@@ -41,6 +43,11 @@ class ShowInterpreter(cmd.Cmd):
line = '? ' + line
return line
+ def close(self):
+ if self.file:
+ self.file.close()
+ self.file = None
+
class PoseidonShell(cmd.Cmd):
intro = 'Welcome to the Poseidon shell. Type help or ? to list commands.\n'
@@ -415,11 +422,13 @@ class PoseidonShell(cmd.Cmd):
@exception
def do_test(self, arg):
- sub_cmd = ShowInterpreter(file=self.file, prompt=self.prompt)
+ sub_cmd = ShowInterpreter(
+ file=self.file, prompt=self.prompt, cmdqueue=self.cmdqueue)
sub_cmd.cmdloop()
@exception
def do_eof(self, arg):
+ self.close()
return True
@exception
