don't create notebook_dir if it doesn't exist

MinRK 12 years ago
parent d37780c6a6
commit 386274488d

@ -521,14 +521,8 @@ class NotebookApp(BaseIPythonApplication):
# If we receive a non-absolute path, make it absolute.
self.notebook_dir = os.path.abspath(new)
return
if os.path.exists(new) and not os.path.isdir(new):
raise TraitError("notebook dir %r is not a directory" % new)
if not os.path.exists(new):
self.log.info("Creating notebook dir %s", new)
try:
os.mkdir(new)
except:
raise TraitError("Couldn't create notebook dir %r" % new)
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.FileNotebookManager.notebook_dir = new

@ -51,11 +51,12 @@ def test_nb_dir():
app = NotebookApp(notebook_dir=td)
nt.assert_equal(app.notebook_dir, td)
def test_create_nb_dir():
def test_no_create_nb_dir():
with TemporaryDirectory() as td:
nbdir = os.path.join(td, 'notebooks')
app = NotebookApp(notebook_dir=nbdir)
nt.assert_equal(app.notebook_dir, nbdir)
app = NotebookApp()
with nt.assert_raises(TraitError):
app.notebook_dir = nbdir
def test_missing_nb_dir():
with TemporaryDirectory() as td:

Loading…
Cancel
Save