##// END OF EJS Templates
Allow starting the server with both file_to_run and notebook_dir...
Thomas Kluyver -
Show More
@@ -344,11 +344,6 b' class NotebookApp(BaseIPythonApplication):'
344
344
345 # file to be opened in the notebook server
345 # file to be opened in the notebook server
346 file_to_run = Unicode('', config=True)
346 file_to_run = Unicode('', config=True)
347 def _file_to_run_changed(self, name, old, new):
348 path, base = os.path.split(new)
349 if path:
350 self.file_to_run = base
351 self.notebook_dir = path
352
347
353 # Network related information
348 # Network related information
354
349
@@ -627,10 +622,6 b' class NotebookApp(BaseIPythonApplication):'
627 info_file = "nbserver-%s.json"%os.getpid()
622 info_file = "nbserver-%s.json"%os.getpid()
628 return os.path.join(self.profile_dir.security_dir, info_file)
623 return os.path.join(self.profile_dir.security_dir, info_file)
629
624
630 notebook_dir = Unicode(py3compat.getcwd(), config=True,
631 help="The directory to use for notebooks and kernels."
632 )
633
634 pylab = Unicode('disabled', config=True,
625 pylab = Unicode('disabled', config=True,
635 help="""
626 help="""
636 DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
627 DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
@@ -648,6 +639,16 b' class NotebookApp(BaseIPythonApplication):'
648 )
639 )
649 self.exit(1)
640 self.exit(1)
650
641
642 notebook_dir = Unicode(config=True,
643 help="The directory to use for notebooks and kernels."
644 )
645
646 def _notebook_dir_default(self):
647 if self.file_to_run:
648 return os.path.dirname(os.path.abspath(self.file_to_run))
649 else:
650 return py3compat.getcwd()
651
651 def _notebook_dir_changed(self, name, old, new):
652 def _notebook_dir_changed(self, name, old, new):
652 """Do a bit of validation of the notebook dir."""
653 """Do a bit of validation of the notebook dir."""
653 if not os.path.isabs(new):
654 if not os.path.isabs(new):
@@ -942,12 +943,12 b' class NotebookApp(BaseIPythonApplication):'
942 browser = None
943 browser = None
943
944
944 if self.file_to_run:
945 if self.file_to_run:
945 fullpath = os.path.join(self.notebook_dir, self.file_to_run)
946 if not os.path.exists(self.file_to_run):
946 if not os.path.exists(fullpath):
947 self.log.critical("%s does not exist" % self.file_to_run)
947 self.log.critical("%s does not exist" % fullpath)
948 self.exit(1)
948 self.exit(1)
949
949
950 uri = url_path_join('notebooks', self.file_to_run)
950 relpath = os.path.relpath(self.file_to_run, self.notebook_dir)
951 uri = url_path_join('notebooks', *relpath.split(os.sep))
951 else:
952 else:
952 uri = 'tree'
953 uri = 'tree'
953 if browser:
954 if browser:
@@ -23,7 +23,10 b' from IPython.html.utils import is_hidden, to_os_path, url_path_join'
23
23
24 class FileContentsManager(ContentsManager):
24 class FileContentsManager(ContentsManager):
25
25
26 root_dir = Unicode(getcwd(), config=True)
26 root_dir = Unicode(config=True)
27
28 def _root_dir_default(self):
29 return self.parent.notebook_dir
27
30
28 save_script = Bool(False, config=True, help='DEPRECATED, IGNORED')
31 save_script = Bool(False, config=True, help='DEPRECATED, IGNORED')
29 def _save_script_changed(self):
32 def _save_script_changed(self):
@@ -12,7 +12,7 b' import os'
12 from tornado import web
12 from tornado import web
13
13
14 from IPython.kernel.multikernelmanager import MultiKernelManager
14 from IPython.kernel.multikernelmanager import MultiKernelManager
15 from IPython.utils.traitlets import Unicode, TraitError
15 from IPython.utils.traitlets import List, Unicode, TraitError
16
16
17 from IPython.html.utils import to_os_path
17 from IPython.html.utils import to_os_path
18 from IPython.utils.py3compat import getcwd
18 from IPython.utils.py3compat import getcwd
@@ -24,7 +24,12 b' class MappingKernelManager(MultiKernelManager):'
24 def _kernel_manager_class_default(self):
24 def _kernel_manager_class_default(self):
25 return "IPython.kernel.ioloop.IOLoopKernelManager"
25 return "IPython.kernel.ioloop.IOLoopKernelManager"
26
26
27 root_dir = Unicode(getcwd(), config=True)
27 kernel_argv = List(Unicode)
28
29 root_dir = Unicode(config=True)
30
31 def _root_dir_default(self):
32 return self.parent.notebook_dir
28
33
29 def _root_dir_changed(self, name, old, new):
34 def _root_dir_changed(self, name, old, new):
30 """Do a bit of validation of the root dir."""
35 """Do a bit of validation of the root dir."""
General Comments 0
You need to be logged in to leave comments. Login now