def execute(self, command): kit = self.kit tags = kit.tags self.update() # Execute the command if use_highlight: self.message(tags.p(tags.nobr(self.prompt, ' ', highlight(command)))) else: self.message(tags.p(tags.nobr(self.prompt, command))) exception = None result = None try: # Capture stdout so we can exec print commands redirector = StdoutRedirector() try: try: result = eval(command, self.globals, self.locals) except SyntaxError: exec command in self.locals finally: # release stdout redirector.close() # print the standard output self.message(html_repr(redirector.get())) except Exception, exception: pass
def message_buffer_body(self, kit): tags = kit.tags id = kit.next_id() command_id = '%s_command' % id prompt_id = '%s_prompt' % id return tags.div( tags.table( tags.tr( tags.td( tags.nobr('', id = prompt_id), style = 'vertical-align: bottom;' ), tags.td( CommandBoxWidget(id = command_id), style = 'width: 100%' ), ), style = ''' width: 100%; ''' ), Javascript( '''shell.open( %s, %s, %s, document.getElementsByTagName('body')[0] );''' % ( repr(self.session_service.base_path), repr(prompt_id), repr(command_id), ), {'shell': javascripts.shell,} ), self.shell_body(kit), )
def message_buffer_body(self, kit): tags = kit.tags id = kit.id host = kit.host debug = kit.debug command_id = '%s_command' % id prompt_id = '%s_prompt' % id session = self.Session() host(service = session, timeout = 20) return tags.div( tags.table( tags.tr( tags.td( tags.nobr('', id = prompt_id), style = 'vertical-align: bottom;' ), tags.td( CommandBoxWidget(id = command_id), style = 'width: 100%' ), ), style = ''' width: 100%; ''' ), Javascript( "shell.open(%s, %s, %s, %s, {'debug': %s});" % ( repr(session.base_path), repr(prompt_id), repr(command_id), repr(id), debug and '1' or '0' ), {'shell': javascripts.shell,} ), self.shell_body(kit), )