Skip to content

Commit

Permalink
Merge pull request #5079 from andfoy/create_tempdir_stderr
Browse files Browse the repository at this point in the history
PR: Create Spyder TEMPDIR if it does not exist when creating new consoles
  • Loading branch information
ccordoba12 authored Aug 30, 2017
2 parents 39fc326 + 93601d7 commit 23da18a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 14 additions & 5 deletions spyder/plugins/ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,16 @@ class IPythonConsole(SpyderPluginWidget):
CONF_SECTION = 'ipython_console'
CONFIGWIDGET_CLASS = IPythonConsoleConfigPage
DISABLE_ACTIONS_WHEN_HIDDEN = False

# Signals
focus_changed = Signal()
edit_goto = Signal((str, int, str), (str, int, str, bool))

# Error messages
permission_error_msg = _("The directory {} is not writable and it is "
"required to create IPython consoles. Please "
"make it writable.")

def __init__(self, parent, testing=False, test_dir=TEMPDIR):
"""Ipython Console constructor."""
if PYQT5:
Expand Down Expand Up @@ -953,9 +958,7 @@ def create_new_client(self, give_focus=True, filename=''):
self.add_tab(client, name=client.get_name(), filename=filename)

if cf is None:
error_msg = _("The directory {} is not writable and it is "
"required to create IPython consoles. Please make "
"it writable.").format(jupyter_runtime_dir())
error_msg = self.permission_error_msg.format(jupyter_runtime_dir())
client.show_kernel_error(error_msg)
return

Expand Down Expand Up @@ -998,7 +1001,13 @@ def create_client_for_kernel(self):
def connect_client_to_kernel(self, client):
"""Connect a client to its kernel"""
connection_file = client.connection_file
stderr_file = client.stderr_file
try:
stderr_file = client.stderr_file
except PermissionError:
error_msg = self.permission_error_msg.format(TEMPDIR)
client.show_kernel_error(error_msg)
return

km, kc = self.create_kernel_manager_and_kernel_client(connection_file,
stderr_file)
# An error occurred if this is True
Expand Down
2 changes: 2 additions & 0 deletions spyder/widgets/ipythonconsole/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def stderr_file(self):
if self.stderr_dir is not None:
stderr_file = osp.join(self.stderr_dir, stderr_file)
else:
if not osp.isdir(TEMPDIR):
os.makedirs(TEMPDIR)
stderr_file = osp.join(TEMPDIR, stderr_file)
return stderr_file

Expand Down

0 comments on commit 23da18a

Please sign in to comment.