def command(self, command): # todo: integrate swil parsing matter # a command parsing stand in, for now # TODO replace this parser with something worthy pos = command.find(" ") if pos != -1: args = command[pos+1:].split(" ") command = command[:pos] else: args = [] # command dispatch if command in self.commands: function = self.commands[command] try: function(self, *args) except TypeError, exception: self.message( """ <p>That is not the <b>proper usage</b> for the <tt>%s</tt> command.</p> """ % inoculate(repr(command)) ) print_exc() except Exception, exception: if hasattr(self, 'message'): self.message(tags.hr().xml) self.message(html_repr(exception)) self.message(tags.hr().xml)
pass try: if result is not None: # print the value of the expression self.message(html_repr(result, host = self.host, depth = self.depth).xml) self.globals['_'] = result self.globals['__'].append(result) except Exception, exception: pass if exception is not None: # print the exception self.message(tags.hr().xml) self.message(html_repr(exception).xml) self.message(tags.hr().xml) self.update() Init.commands.load( module_path(__file__, 'commands.py'), module_path(__file__, '..', 'sh', 'general_commands.py'), ) class StdoutRedirector(object): """ Captures stdout from instantiation until close() is called. This is not really thread safe! It should be fine as long as we stay single threadded.
self.message(html_repr(redirector.get())) except Exception, exception: pass try: if result is not None: # print the value of the expression self.message(html_repr(result, host = self.host, depth = self.depth)) self.globals['_'] = result self.globals['__'].append(result) except Exception, exception: pass if exception is not None: # print the exception self.message(tags.hr()) self.message(html_repr(exception)) self.message(tags.hr()) self.update() class Service(ShellService): Mode = Mode PyshService = Service PyshMode = Mode