def exec_queue(self): """ Execute lines in self.queue """ if len(self.queue) == 0: return SUCCESS for line in self.queue: # split on ';' and exec the line lines = split_cmd_line(line) for s in lines: stop = self.exec_line(s) if stop == QUIT: self.queue = [] return QUIT elif (stop == EXECERROR) and (self.error_break == True): self.queue = [] print "Error executing shell.queue" return EXECERROR return SUCCESS
def loop(self,): """ The prompt loop Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument. Modified from cmd.Cmd.cmdloop. Note for the python interpretor to work it is important that blank lines are passed, and that lines are not stripped entirely (ie leave white space on left) """ stop = COMPLETE while stop != QUIT: if stop == CONTINUE: prompt = self.ps2 else: prompt = self.ps1 if self.use_rawinput: try: line = raw_input(prompt) except EOFError: line = 'quit' else: self.stdout.write(prompt) self.stdout.flush() line = self.stdin.readline() if line == None: line = 'quit' else: #line = line[:-1] # chop \n line = line.rstrip() # chop \n # split on ';' and exec the line lines = split_cmd_line(line) for s in lines: stop = self.exec_line(s) if stop == QUIT: break return SUCCESS
def loop(self, ): """ The prompt loop Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument. Modified from cmd.Cmd.cmdloop. Note for the python interpretor to work it is important that blank lines are passed, and that lines are not stripped entirely (ie leave white space on left) """ stop = COMPLETE while stop != QUIT: if stop == CONTINUE: prompt = self.ps2 else: prompt = self.ps1 if self.use_rawinput: try: line = raw_input(prompt) except EOFError: line = 'quit' else: self.stdout.write(prompt) self.stdout.flush() line = self.stdin.readline() if line == None: line = 'quit' else: #line = line[:-1] # chop \n line = line.rstrip() # chop \n # split on ';' and exec the line lines = split_cmd_line(line) for s in lines: stop = self.exec_line(s) if stop == QUIT: break return SUCCESS