##// END OF EJS Templates
fixup positional arg parsing in notebook app...
MinRK -
Show More
@@ -333,6 +333,11 b' class NotebookApp(BaseIPythonApplication):'
333
333
334 # file to be opened in the notebook server
334 # file to be opened in the notebook server
335 file_to_run = Unicode('')
335 file_to_run = Unicode('')
336 def _file_to_run_changed(self, name, old, new):
337 path, base = os.path.split(new)
338 if path:
339 self.file_to_run = base
340 self.notebook_dir = path
336
341
337 # Network related information.
342 # Network related information.
338
343
@@ -546,7 +551,12 b' class NotebookApp(BaseIPythonApplication):'
546 self.log.critical("No such file or directory: %s", f)
551 self.log.critical("No such file or directory: %s", f)
547 self.exit(1)
552 self.exit(1)
548 if os.path.isdir(f):
553 if os.path.isdir(f):
554 old = self.notebook_dir
549 self.notebook_dir = f
555 self.notebook_dir = f
556 if old == self.notebook_dir:
557 # force trigger on-change event if it didn't fire,
558 # so that descendent config fires
559 self._notebook_dir_changed('notebook_dir', old, self.notebook_dir)
550 elif os.path.isfile(f):
560 elif os.path.isfile(f):
551 self.file_to_run = f
561 self.file_to_run = f
552
562
@@ -799,24 +809,17 b' class NotebookApp(BaseIPythonApplication):'
799 self.log.warn('No web browser found: %s.' % e)
809 self.log.warn('No web browser found: %s.' % e)
800 browser = None
810 browser = None
801
811
802 f = self.file_to_run
812 if self.file_to_run:
803 if f:
813 fullpath = os.path.join(self.notebook_dir, self.file_to_run)
804 nbdir = os.path.abspath(self.notebook_manager.notebook_dir)
814 if not os.path.exists(fullpath):
805 if f.startswith(nbdir):
815 self.log.critical("%s does not exist" % fullpath)
806 f = f[len(nbdir):]
816 self.exit(1)
807 else:
817
808 self.log.warn(
818 uri = url_path_join('notebooks', self.file_to_run)
809 "Probably won't be able to open notebook %s "
810 "because it is not in notebook_dir %s",
811 f, nbdir,
812 )
813
814 if os.path.isfile(self.file_to_run):
815 url = url_path_join('notebooks', f)
816 else:
819 else:
817 url = url_path_join('tree', f)
820 uri = 'tree'
818 if browser:
821 if browser:
819 b = lambda : browser.open("%s%s" % (self.connection_url, url),
822 b = lambda : browser.open(url_path_join(self.connection_url, uri),
820 new=2)
823 new=2)
821 threading.Thread(target=b).start()
824 threading.Thread(target=b).start()
822 try:
825 try:
General Comments 0
You need to be logged in to leave comments. Login now