mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
No interactive output from IPython console (PY-26479)
Do not patch sys.stdout to postpone banner showing, just call an appropriate function before execution of greeting message.
This commit is contained in:
@@ -184,7 +184,6 @@ class BaseInterpreterInterface:
|
||||
self.exec_queue = _queue.Queue(0)
|
||||
self.buffer = None
|
||||
self.banner_shown = False
|
||||
self.default_banner = ''
|
||||
|
||||
def build_banner(self):
|
||||
return 'print({0})\n'.format(repr(self.get_greeting_msg()))
|
||||
|
||||
@@ -4,7 +4,6 @@ import sys
|
||||
from _pydev_bundle.pydev_console_utils import BaseInterpreterInterface
|
||||
from _pydev_bundle.pydev_ipython_console_011 import get_pydev_frontend
|
||||
from _pydevd_bundle.pydevd_constants import dict_iter_items
|
||||
from _pydevd_bundle.pydevd_io import IOBuf
|
||||
|
||||
|
||||
# Uncomment to force PyDev standard shell.
|
||||
@@ -18,25 +17,21 @@ class InterpreterInterface(BaseInterpreterInterface):
|
||||
The methods in this class should be registered in the xml-rpc server.
|
||||
'''
|
||||
|
||||
def __init__(self, host, client_port, mainThread, show_banner=True):
|
||||
BaseInterpreterInterface.__init__(self, mainThread)
|
||||
def __init__(self, host, client_port, main_thread, show_banner=True):
|
||||
BaseInterpreterInterface.__init__(self, main_thread)
|
||||
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.interpreter = get_pydev_frontend(host, client_port)
|
||||
self._input_error_printed = False
|
||||
self.notification_succeeded = False
|
||||
self.notification_tries = 0
|
||||
self.notification_max_tries = 3
|
||||
self.show_banner = show_banner
|
||||
|
||||
def get_greeting_msg(self):
|
||||
return self.interpreter.get_greeting_msg() + "\n" + self.default_banner
|
||||
if self.show_banner:
|
||||
self.interpreter.show_banner()
|
||||
return self.interpreter.get_greeting_msg()
|
||||
|
||||
def do_add_exec(self, code_fragment):
|
||||
self.notify_about_magic()
|
||||
|
||||
@@ -318,21 +318,18 @@ class _PyDevFrontEnd:
|
||||
|
||||
version = release.__version__
|
||||
|
||||
def __init__(self, show_banner=True):
|
||||
def __init__(self):
|
||||
# Create and initialize our IPython instance.
|
||||
if hasattr(PyDevTerminalInteractiveShell, '_instance') and PyDevTerminalInteractiveShell._instance is not None:
|
||||
self.ipython = PyDevTerminalInteractiveShell._instance
|
||||
else:
|
||||
self.ipython = PyDevTerminalInteractiveShell.instance()
|
||||
|
||||
if show_banner:
|
||||
# Display the IPython banner, this has version info and
|
||||
# help info
|
||||
self.ipython.show_banner()
|
||||
|
||||
self._curr_exec_line = 0
|
||||
self._curr_exec_lines = []
|
||||
|
||||
def show_banner(self):
|
||||
self.ipython.show_banner()
|
||||
|
||||
def update(self, globals, locals):
|
||||
ns = self.ipython.user_ns
|
||||
@@ -491,9 +488,10 @@ class _PyDevFrontEndContainer:
|
||||
_instance = None
|
||||
_last_host_port = None
|
||||
|
||||
def get_pydev_frontend(pydev_host, pydev_client_port, show_banner=True):
|
||||
|
||||
def get_pydev_frontend(pydev_host, pydev_client_port):
|
||||
if _PyDevFrontEndContainer._instance is None:
|
||||
_PyDevFrontEndContainer._instance = _PyDevFrontEnd(show_banner=show_banner)
|
||||
_PyDevFrontEndContainer._instance = _PyDevFrontEnd()
|
||||
|
||||
if _PyDevFrontEndContainer._last_host_port != (pydev_host, pydev_client_port):
|
||||
_PyDevFrontEndContainer._last_host_port = pydev_host, pydev_client_port
|
||||
|
||||
@@ -89,7 +89,7 @@ class InterpreterInterface(BaseInterpreterInterface):
|
||||
The methods in this class should be registered in the xml-rpc server.
|
||||
'''
|
||||
|
||||
def __init__(self, host, client_port, mainThread, show_banner=True):
|
||||
def __init__(self, host, client_port, mainThread):
|
||||
BaseInterpreterInterface.__init__(self, mainThread)
|
||||
self.client_port = client_port
|
||||
self.host = host
|
||||
|
||||
Reference in New Issue
Block a user