Clean up get_kernel_path logic

Thomas Kluyver 12 years ago
parent fd2588612a
commit d273b56044

@ -187,8 +187,12 @@ class ContentsManager(LoggingConfigurable):
KernelManagers can turn this value into a filesystem path,
or ignore it altogether.
The default value here will start kernels in the directory of the
notebook server. FileContentsManager overrides this to use the
directory containing the notebook.
"""
return path
return ''
def increment_filename(self, filename, path='', insert=''):
"""Increment a filename until it is unique.

@ -54,14 +54,10 @@ class MappingKernelManager(MultiKernelManager):
def cwd_for_path(self, path):
"""Turn API path into absolute OS path."""
# short circuit for NotebookManagers that pass in absolute paths
if os.path.exists(path):
return path
os_path = to_os_path(path, self.root_dir)
# in the case of notebooks and kernels not being on the same filesystem,
# walk up to root_dir if the paths don't exist
while not os.path.exists(os_path) and os_path != self.root_dir:
while not os.path.isdir(os_path) and os_path != self.root_dir:
os_path = os.path.dirname(os_path)
return os_path

Loading…
Cancel
Save