Show More
@@ -1,23 +1,11 b'' | |||
|
1 | 1 | # coding: utf-8 |
|
2 | """A tornado based IPython notebook server. | |
|
2 | """A tornado based IPython notebook server.""" | |
|
3 | 3 | |
|
4 | Authors: | |
|
4 | # Copyright (c) IPython Development Team. | |
|
5 | # Distributed under the terms of the Modified BSD License. | |
|
5 | 6 | |
|
6 | * Brian Granger | |
|
7 | """ | |
|
8 | 7 | from __future__ import print_function |
|
9 | #----------------------------------------------------------------------------- | |
|
10 | # Copyright (C) 2013 The IPython Development Team | |
|
11 | # | |
|
12 | # Distributed under the terms of the BSD License. The full license is in | |
|
13 | # the file COPYING, distributed as part of this software. | |
|
14 | #----------------------------------------------------------------------------- | |
|
15 | 8 | |
|
16 | #----------------------------------------------------------------------------- | |
|
17 | # Imports | |
|
18 | #----------------------------------------------------------------------------- | |
|
19 | ||
|
20 | # stdlib | |
|
21 | 9 | import errno |
|
22 | 10 | import io |
|
23 | 11 | import json |
@@ -33,7 +21,6 b' import time' | |||
|
33 | 21 | import webbrowser |
|
34 | 22 | |
|
35 | 23 | |
|
36 | # Third party | |
|
37 | 24 | # check for pyzmq 2.1.11 |
|
38 | 25 | from IPython.utils.zmqrelated import check_for_zmq |
|
39 | 26 | check_for_zmq('2.1.11', 'IPython.html') |
@@ -61,7 +48,6 b' if version_info < (3,1,0):' | |||
|
61 | 48 | from tornado import httpserver |
|
62 | 49 | from tornado import web |
|
63 | 50 | |
|
64 | # Our own libraries | |
|
65 | 51 | from IPython.html import DEFAULT_STATIC_FILES_PATH |
|
66 | 52 | from .base.handlers import Template404 |
|
67 | 53 | from .log import log_request |
@@ -75,15 +61,12 b' from .base.handlers import AuthenticatedFileHandler, FileFindHandler' | |||
|
75 | 61 | |
|
76 | 62 | from IPython.config import Config |
|
77 | 63 | from IPython.config.application import catch_config_error, boolean_flag |
|
78 |
from IPython.core.application import |
|
|
79 | from IPython.core.profiledir import ProfileDir | |
|
80 | from IPython.consoleapp import IPythonConsoleApp | |
|
81 | from IPython.kernel import swallow_argv | |
|
82 | from IPython.kernel.zmq.session import default_secure | |
|
83 | from IPython.kernel.zmq.kernelapp import ( | |
|
84 | kernel_flags, | |
|
85 | kernel_aliases, | |
|
64 | from IPython.core.application import ( | |
|
65 | BaseIPythonApplication, base_flags, base_aliases, | |
|
86 | 66 | ) |
|
67 | from IPython.core.profiledir import ProfileDir | |
|
68 | from IPython.kernel import KernelManager | |
|
69 | from IPython.kernel.zmq.session import default_secure, Session | |
|
87 | 70 | from IPython.nbformat.sign import NotebookNotary |
|
88 | 71 | from IPython.utils.importstring import import_item |
|
89 | 72 | from IPython.utils import submodule |
@@ -248,11 +231,15 b' class NbserverListApp(BaseIPythonApplication):' | |||
|
248 | 231 | # Aliases and Flags |
|
249 | 232 | #----------------------------------------------------------------------------- |
|
250 | 233 | |
|
251 |
flags = dict( |
|
|
234 | flags = dict(base_flags) | |
|
252 | 235 | flags['no-browser']=( |
|
253 | 236 | {'NotebookApp' : {'open_browser' : False}}, |
|
254 | 237 | "Don't open the notebook in a browser after startup." |
|
255 | 238 | ) |
|
239 | flags['pylab']=( | |
|
240 | {'NotebookApp' : {'pylab' : 'warn'}}, | |
|
241 | "DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib." | |
|
242 | ) | |
|
256 | 243 | flags['no-mathjax']=( |
|
257 | 244 | {'NotebookApp' : {'enable_mathjax' : False}}, |
|
258 | 245 | """Disable MathJax |
@@ -270,12 +257,7 b" flags.update(boolean_flag('script', 'FileNotebookManager.save_script'," | |||
|
270 | 257 | 'Auto-save a .py script everytime the .ipynb notebook is saved', |
|
271 | 258 | 'Do not auto-save .py scripts for every notebook')) |
|
272 | 259 | |
|
273 | # the flags that are specific to the frontend | |
|
274 | # these must be scrubbed before being passed to the kernel, | |
|
275 | # or it will raise an error on unrecognized flags | |
|
276 | notebook_flags = ['no-browser', 'no-mathjax', 'script', 'no-script'] | |
|
277 | ||
|
278 | aliases = dict(kernel_aliases) | |
|
260 | aliases = dict(base_aliases) | |
|
279 | 261 | |
|
280 | 262 | aliases.update({ |
|
281 | 263 | 'ip': 'NotebookApp.ip', |
@@ -286,15 +268,9 b' aliases.update({' | |||
|
286 | 268 | 'certfile': 'NotebookApp.certfile', |
|
287 | 269 | 'notebook-dir': 'NotebookApp.notebook_dir', |
|
288 | 270 | 'browser': 'NotebookApp.browser', |
|
271 | 'pylab': 'NotebookApp.pylab', | |
|
289 | 272 | }) |
|
290 | 273 | |
|
291 | # remove ipkernel flags that are singletons, and don't make sense in | |
|
292 | # multi-kernel evironment: | |
|
293 | aliases.pop('f', None) | |
|
294 | ||
|
295 | notebook_aliases = [u'port', u'port-retries', u'ip', u'keyfile', u'certfile', | |
|
296 | u'notebook-dir', u'profile', u'profile-dir', 'browser'] | |
|
297 | ||
|
298 | 274 | #----------------------------------------------------------------------------- |
|
299 | 275 | # NotebookApp |
|
300 | 276 | #----------------------------------------------------------------------------- |
@@ -310,9 +286,13 b' class NotebookApp(BaseIPythonApplication):' | |||
|
310 | 286 | HTML5/Javascript Notebook client. |
|
311 | 287 | """ |
|
312 | 288 | examples = _examples |
|
289 | aliases = aliases | |
|
290 | flags = flags | |
|
313 | 291 | |
|
314 | classes = IPythonConsoleApp.classes + [MappingKernelManager, NotebookManager, | |
|
315 | FileNotebookManager, NotebookNotary] | |
|
292 | classes = [ | |
|
293 | KernelManager, ProfileDir, Session, MappingKernelManager, | |
|
294 | NotebookManager, FileNotebookManager, NotebookNotary, | |
|
295 | ] | |
|
316 | 296 | flags = Dict(flags) |
|
317 | 297 | aliases = Dict(aliases) |
|
318 | 298 | |
@@ -524,6 +504,23 b' class NotebookApp(BaseIPythonApplication):' | |||
|
524 | 504 | notebook_dir = Unicode(py3compat.getcwd(), config=True, |
|
525 | 505 | help="The directory to use for notebooks and kernels." |
|
526 | 506 | ) |
|
507 | ||
|
508 | pylab = Unicode('disabled', config=True, | |
|
509 | help=""" | |
|
510 | DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib. | |
|
511 | """ | |
|
512 | ) | |
|
513 | def _pylab_changed(self, name, old, new): | |
|
514 | """when --pylab is specified, display a warning and exit""" | |
|
515 | if new != 'warn': | |
|
516 | backend = ' %s' % new | |
|
517 | else: | |
|
518 | backend = '' | |
|
519 | self.log.error("Support for specifying --pylab on the command line has been removed.") | |
|
520 | self.log.error( | |
|
521 | "Please use `%pylab{0}` or `%matplotlib{0}` in the notebook itself.".format(backend) | |
|
522 | ) | |
|
523 | self.exit(1) | |
|
527 | 524 | |
|
528 | 525 | def _notebook_dir_changed(self, name, old, new): |
|
529 | 526 | """Do a bit of validation of the notebook dir.""" |
@@ -561,16 +558,7 b' class NotebookApp(BaseIPythonApplication):' | |||
|
561 | 558 | |
|
562 | 559 | def init_kernel_argv(self): |
|
563 | 560 | """construct the kernel arguments""" |
|
564 | # Scrub frontend-specific flags | |
|
565 | self.kernel_argv = swallow_argv(self.argv, notebook_aliases, notebook_flags) | |
|
566 | if any(arg.startswith(u'--pylab') for arg in self.kernel_argv): | |
|
567 | self.log.warn('\n '.join([ | |
|
568 | "Starting all kernels in pylab mode is not recommended,", | |
|
569 | "and will be disabled in a future release.", | |
|
570 | "Please use the %matplotlib magic to enable matplotlib instead.", | |
|
571 | "pylab implies many imports, which can have confusing side effects", | |
|
572 | "and harm the reproducibility of your notebooks.", | |
|
573 | ])) | |
|
561 | self.kernel_argv = [] | |
|
574 | 562 | # Kernel should inherit default config file from frontend |
|
575 | 563 | self.kernel_argv.append("--IPKernelApp.parent_appname='%s'" % self.name) |
|
576 | 564 | # Kernel should get *absolute* path to profile directory |
General Comments 0
You need to be logged in to leave comments.
Login now