Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problems when connecting to external kernels #3540

Merged
merged 4 commits into from
Oct 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion spyder/plugins/ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ def _create_client_for_kernel(self, connection_file, hostname, sshkey,
password):
# Verifying if the connection file exists
try:
find_connection_file(osp.basename(connection_file))
connection_file = find_connection_file(osp.basename(connection_file))
except (IOError, UnboundLocalError):
QMessageBox.critical(self, _('IPython'),
_("Unable to connect to "
Expand All @@ -1369,6 +1369,7 @@ def _create_client_for_kernel(self, connection_file, hostname, sshkey,
# Getting the master name that corresponds to the client
# (i.e. the i in i/A)
master_name = None
external_kernel = False
slave_ord = ord('A') - 1
kernel_manager = None
for cl in self.get_clients():
Expand All @@ -1387,6 +1388,7 @@ def _create_client_for_kernel(self, connection_file, hostname, sshkey,
if master_name is None:
self.master_clients += 1
master_name = to_text_string(self.master_clients)
external_kernel = True

# Set full client name
name = master_name + '/' + chr(slave_ord + 1)
Expand All @@ -1400,6 +1402,7 @@ def _create_client_for_kernel(self, connection_file, hostname, sshkey,
connection_file=connection_file,
menu_actions=self.menu_actions,
hostname=hostname,
external_kernel=external_kernel,
slave=True)

# Create kernel client
Expand Down
4 changes: 3 additions & 1 deletion spyder/widgets/ipythonconsole/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class ClientWidget(QWidget, SaveHistoryMixin):
def __init__(self, plugin, name, history_filename, config_options,
additional_options, interpreter_versions,
connection_file=None, hostname=None,
menu_actions=None, slave=False):
menu_actions=None, slave=False,
external_kernel=False):
super(ClientWidget, self).__init__(plugin)
SaveHistoryMixin.__init__(self)

Expand All @@ -104,6 +105,7 @@ def __init__(self, plugin, name, history_filename, config_options,
self.shellwidget = ShellWidget(config=config_options,
additional_options=additional_options,
interpreter_versions=interpreter_versions,
external_kernel=external_kernel,
local_kernel=True)
self.shellwidget.hide()
self.infowidget = WebView(self)
Expand Down
5 changes: 3 additions & 2 deletions spyder/widgets/ipythonconsole/namespacebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def _handle_status(self, msg):
self._kernel_is_starting = True
elif state == 'idle' and msg_type == 'shutdown_request':
# This handles restarts asked by the user
self.set_namespace_view_settings()
self.refresh_namespacebrowser()
if self.namespacebrowser is not None:
self.set_namespace_view_settings()
self.refresh_namespacebrowser()
else:
super(NamepaceBrowserWidget, self)._handle_status(msg)
11 changes: 8 additions & 3 deletions spyder/widgets/ipythonconsole/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class ShellWidget(NamepaceBrowserWidget, HelpWidget, DebuggingWidget):
new_client = Signal()
sig_got_reply = Signal()

def __init__(self, additional_options, interpreter_versions, *args, **kw):
def __init__(self, additional_options, interpreter_versions,
external_kernel, *args, **kw):
# To override the Qt widget used by RichJupyterWidget
self.custom_control = ControlWidget
self.custom_page_control = PageControlWidget
Expand All @@ -57,10 +58,11 @@ def __init__(self, additional_options, interpreter_versions, *args, **kw):

self.set_background_color()

# --- Spyder variables ---
# Additional variables
self.ipyclient = None
self.external_kernel = external_kernel

# --- Keyboard shortcuts ---
# Keyboard shortcuts
self.shortcuts = self.create_shortcuts()

# To save kernel replies in silent execution
Expand Down Expand Up @@ -245,6 +247,9 @@ def _banner_default(self):
Reimplement banner creation to let the user decide if he wants a
banner or not
"""
# Don't change banner for external kernels
if self.external_kernel:
return ''
show_banner_o = self.additional_options['show_banner']
if show_banner_o:
return self.long_banner()
Expand Down