|
|
|
|
@ -754,15 +754,19 @@ class NotebookApp(JupyterApp):
|
|
|
|
|
else:
|
|
|
|
|
return py3compat.getcwd()
|
|
|
|
|
|
|
|
|
|
def _notebook_dir_validate(self, value, trait):
|
|
|
|
|
# Strip any trailing slashes
|
|
|
|
|
value = value.rstrip(os.sep)
|
|
|
|
|
|
|
|
|
|
if not os.path.isabs(value):
|
|
|
|
|
# If we receive a non-absolute path, make it absolute.
|
|
|
|
|
value = os.path.abspath(value)
|
|
|
|
|
if not os.path.isdir(value):
|
|
|
|
|
raise TraitError("No such notebook dir: %r" % value)
|
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
def _notebook_dir_changed(self, name, old, new):
|
|
|
|
|
"""Do a bit of validation of the notebook dir."""
|
|
|
|
|
if not os.path.isabs(new):
|
|
|
|
|
# If we receive a non-absolute path, make it absolute.
|
|
|
|
|
self.notebook_dir = os.path.abspath(new)
|
|
|
|
|
return
|
|
|
|
|
if not os.path.isdir(new):
|
|
|
|
|
raise TraitError("No such notebook dir: %r" % new)
|
|
|
|
|
|
|
|
|
|
# setting App.notebook_dir implies setting notebook and kernel dirs as well
|
|
|
|
|
self.config.FileContentsManager.root_dir = new
|
|
|
|
|
self.config.MappingKernelManager.root_dir = new
|
|
|
|
|
|