def push(self, line, frame, buffer_output=True): """Change built-in stdout and stderr methods by the new custom StdMessage. execute the InteractiveConsole.push. Change the stdout and stderr back be the original built-ins :param buffer_output: if False won't redirect the output. Return boolean (True if more input is required else False), output_messages and input_messages """ self.__buffer_output = buffer_output more = False if buffer_output: original_stdout = sys.stdout original_stderr = sys.stderr try: try: self.frame = frame if buffer_output: out = sys.stdout = IOBuf() err = sys.stderr = IOBuf() more = self.add_exec(line) except Exception: exc = get_exception_traceback_str() if buffer_output: err.buflist.append("Internal Error: %s" % (exc, )) else: sys.stderr.write("Internal Error: %s\n" % (exc, )) finally: # Remove frame references. self.frame = None frame = None if buffer_output: sys.stdout = original_stdout sys.stderr = original_stderr if buffer_output: return more, out.buflist, err.buflist else: return more, [], []
def __init__(self, host, client_port, mainThread, show_banner=True): BaseInterpreterInterface.__init__(self, mainThread) self.client_port = client_port self.host = host # Wrap output to handle IPython's banner and show it in appropriate time original_stdout = sys.stdout sys.stdout = IOBuf() self.interpreter = get_pydev_frontend(host, client_port, show_banner=show_banner) self.default_banner = sys.stdout.getvalue() sys.stdout = original_stdout self._input_error_printed = False self.notification_succeeded = False self.notification_tries = 0 self.notification_max_tries = 3