##// END OF EJS Templates
added --browser option to notebook...
Paul Ivanov -
Show More
@@ -208,6 +208,7 b' aliases.update({'
208 'keyfile': 'NotebookApp.keyfile',
208 'keyfile': 'NotebookApp.keyfile',
209 'certfile': 'NotebookApp.certfile',
209 'certfile': 'NotebookApp.certfile',
210 'notebook-dir': 'NotebookManager.notebook_dir',
210 'notebook-dir': 'NotebookManager.notebook_dir',
211 'browser': 'NotebookApp.browser',
211 })
212 })
212
213
213 # remove ipkernel flags that are singletons, and don't make sense in
214 # remove ipkernel flags that are singletons, and don't make sense in
@@ -280,22 +281,22 b' class NotebookApp(BaseIPythonApplication):'
280 The string should be of the form type:salt:hashed-password.
281 The string should be of the form type:salt:hashed-password.
281 """
282 """
282 )
283 )
283
284
284 open_browser = Bool(True, config=True,
285 open_browser = Bool(True, config=True,
285 help="""Whether to open in a browser after starting.
286 help="""Whether to open in a browser after starting.
286 The specific browser used is platform dependent and
287 The specific browser used is platform dependent and
287 determined by the python standard library `webbrowser`
288 determined by the python standard library `webbrowser`
288 module, which allows setting of the BROWSER
289 module, unless it is overridden using the --browser
289 environment variable to override it. As a one-time
290 (NotebookApp.browser) configuration option.
290 change, you can start the notebook using:
291
292 BROWSER=firefox ipython notebook
293
294 To make the change more permanent, modify your
295 ~/.bashrc you can include a line like the following:
296
297 export BROWSER=firefox
298 """)
291 """)
292
293 browser = Unicode(u'', config=True,
294 help="""Specify which browser to use when opening the
295 notebook. If not specified, the default browser will be
296 determined by the `webbrowser` standard library module,
297 which allows setting of the BROWSER environment variable
298 to override it.
299 """)
299
300
300 read_only = Bool(False, config=True,
301 read_only = Bool(False, config=True,
301 help="Whether to prevent editing/execution of notebooks."
302 help="Whether to prevent editing/execution of notebooks."
@@ -440,7 +441,11 b' class NotebookApp(BaseIPythonApplication):'
440
441
441 if self.open_browser:
442 if self.open_browser:
442 ip = self.ip or '127.0.0.1'
443 ip = self.ip or '127.0.0.1'
443 b = lambda : webbrowser.open("%s://%s:%i%s" % (proto, ip, self.port,
444 if len(self.browser) == 0:
445 browser = webbrowser.get()
446 else:
447 browser = webbrowser.get(self.browser)
448 b = lambda : browser.open("%s://%s:%i%s" % (proto, ip, self.port,
444 self.base_project_url),
449 self.base_project_url),
445 new=2)
450 new=2)
446 threading.Thread(target=b).start()
451 threading.Thread(target=b).start()
General Comments 0
You need to be logged in to leave comments. Login now