##// END OF EJS Templates
ENH: Open a notebook from the command line...
Puneeth Chaganti -
Show More
@@ -257,6 +257,9 class NotebookApp(BaseIPythonApplication):
257 257 # create requested profiles by default, if they don't exist:
258 258 auto_create = Bool(True)
259 259
260 # file to be opened in the notebook server
261 file_to_run = Unicode('')
262
260 263 # Network related information.
261 264
262 265 ip = Unicode(LOCALHOST, config=True,
@@ -392,6 +395,10 class NotebookApp(BaseIPythonApplication):
392 395 # Kernel should inherit default config file from frontend
393 396 self.kernel_argv.append("--KernelApp.parent_appname='%s'"%self.name)
394 397
398 if self.extra_args:
399 self.file_to_run = os.path.abspath(self.extra_args[0])
400 self.config.NotebookManager.notebook_dir = os.path.dirname(self.file_to_run)
401
395 402 def init_configurables(self):
396 403 # force Session default to be secure
397 404 default_secure(self.config)
@@ -540,9 +547,20 class NotebookApp(BaseIPythonApplication):
540 547 browser = webbrowser.get(self.browser)
541 548 else:
542 549 browser = webbrowser.get()
543 b = lambda : browser.open("%s://%s:%i%s" % (proto, ip, self.port,
544 self.base_project_url),
545 new=2)
550
551 if self.file_to_run:
552 filename, _ = os.path.splitext(os.path.basename(self.file_to_run))
553 for nb in self.notebook_manager.list_notebooks():
554 if filename == nb['name']:
555 url = nb['notebook_id']
556 break
557 else:
558 url = ''
559 else:
560 url = ''
561 b = lambda : browser.open("%s://%s:%i%s%s" % (proto, ip,
562 self.port, self.base_project_url, url),
563 new=2)
546 564 threading.Thread(target=b).start()
547 565 try:
548 566 ioloop.IOLoop.instance().start()
General Comments 0
You need to be logged in to leave comments. Login now