Permalink
Browse files

More review changes.

* Favicon.ico is served.
* Test suit now passes.
* Help links work for for me.
* Other changes made to address inline comments.
* The printing of long lines is an extremely subtle issue and I will open an issue for it.
* zmqws.py is completely gone so the naked print is not an issue.
* ipython-notebook removed from scripts.
* Updated copyright and authors of files.
* Fixed missing docstrings in IPython.nbformat.
  • Loading branch information...
ellisonbg committed Aug 17, 2011
1 parent 2c580e7 commit a661b7c0002f3bc8a60592f87b0a0241f0b65320
Showing with 442 additions and 71 deletions.
  1. +0 −8 IPython/__init__.py
  2. +1 −2 IPython/core/magic.py
  3. +5 −4 IPython/core/profileapp.py
  4. +13 −2 IPython/frontend/html/notebook/handlers.py
  5. +8 −3 IPython/frontend/html/notebook/kernelmanager.py
  6. +16 −10 IPython/frontend/html/notebook/notebookapp.py
  7. +11 −6 IPython/frontend/html/notebook/notebookmanager.py
  8. BIN IPython/frontend/html/notebook/static/favicon.ico
  9. +6 −0 IPython/frontend/html/notebook/static/js/cell.js
  10. +6 −0 IPython/frontend/html/notebook/static/js/codecell.js
  11. +6 −0 IPython/frontend/html/notebook/static/js/kernel.js
  12. +6 −0 IPython/frontend/html/notebook/static/js/kernelstatus.js
  13. +6 −0 IPython/frontend/html/notebook/static/js/layout.js
  14. +6 −0 IPython/frontend/html/notebook/static/js/leftpanel.js
  15. +7 −0 IPython/frontend/html/notebook/static/js/namespace.js
  16. +6 −0 IPython/frontend/html/notebook/static/js/nbbrowser_main.js
  17. +6 −0 IPython/frontend/html/notebook/static/js/notebook.js
  18. +6 −0 IPython/frontend/html/notebook/static/js/notebook_main.js
  19. +7 −1 IPython/frontend/html/notebook/static/js/notebooklist.js
  20. +6 −0 IPython/frontend/html/notebook/static/js/pager.js
  21. +7 −1 IPython/frontend/html/notebook/static/js/panelsection.js
  22. +7 −1 IPython/frontend/html/notebook/static/js/savewidget.js
  23. +6 −0 IPython/frontend/html/notebook/static/js/textcell.js
  24. +6 −0 IPython/frontend/html/notebook/static/js/utils.js
  25. +0 −13 IPython/frontend/html/notebook/tests/test_kernelsession.py
  26. +22 −6 IPython/frontend/html/notebook/zmqhttp.py
  27. +21 −0 IPython/nbformat/current.py
  28. +12 −0 IPython/nbformat/v1/__init__.py
  29. +11 −0 IPython/nbformat/v1/convert.py
  30. +20 −1 IPython/nbformat/v1/nbbase.py
  31. +20 −1 IPython/nbformat/v1/nbjson.py
  32. +21 −0 IPython/nbformat/v1/rwbase.py
  33. +20 −0 IPython/nbformat/v2/__init__.py
  34. +31 −1 IPython/nbformat/v2/convert.py
  35. +25 −1 IPython/nbformat/v2/nbbase.py
  36. +20 −1 IPython/nbformat/v2/nbjson.py
  37. +20 −1 IPython/nbformat/v2/nbpy.py
  38. +21 −1 IPython/nbformat/v2/nbxml.py
  39. +24 −0 IPython/nbformat/v2/rwbase.py
  40. +0 −7 IPython/scripts/ipython-notebook
View
@@ -43,14 +43,6 @@
from .config.loader import Config
from .core import release
from .core.application import Application
-# Todo: Should these be imported here? We need to rethink what is imported in
-# this module.
-#from .core.display import (
-# display, display_pretty, display_html, display_latex,
-# display_png, display_jpeg, display_svg, display_json,
-# display_javascript, HTML, SVG, Math, Image, JSON,
-# Javascript, Pretty
-#)
from .frontend.terminal.embed import embed
from .core.error import TryNext
from .core.interactiveshell import InteractiveShell
View
@@ -48,8 +48,7 @@
from IPython.core.fakemodule import FakeModule
from IPython.core.profiledir import ProfileDir
from IPython.core.macro import Macro
-from IPython.core import magic_arguments
-from IPython.core import page
+from IPython.core import magic_arguments, page
from IPython.core.prefilter import ESC_MAGIC
from IPython.lib.pylabtools import mpl_runner
from IPython.testing.skipdoctest import skip_doctest
@@ -195,11 +195,12 @@ def init_config_files(self):
apps.append(IPythonQtConsoleApp)
try:
from IPython.frontend.html.notebook.notebookapp import IPythonNotebookApp
- except Exception:
- # this should be ImportError, but under weird circumstances
- # this might be an AttributeError, or possibly others
- # in any case, nothing should cause the profile creation to crash.
+ except ImportError:
pass
+ except Exception:
+ self.log.debug('Unexpected error when importing IPythonNotebookApp',
+ exc_info=True
+ )
else:
apps.append(IPythonNotebookApp)
if self.parallel:
@@ -1,9 +1,20 @@
-"""Tornado handlers for the notebook."""
+"""Tornado handlers for the notebook.
+
+Authors:
+
+* Brian Granger
+"""
#-----------------------------------------------------------------------------
-# Imports
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
from tornado import web
from tornado import websocket
@@ -1,10 +1,15 @@
-"""A kernel manager for multiple kernels."""
+"""A kernel manager for multiple kernels.
+
+Authors:
+
+* Brian Granger
+"""
#-----------------------------------------------------------------------------
-# Copyright (C) 2011 The IPython Development Team
+# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
-# the file COPYING.txt, distributed as part of this software.
+# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
@@ -1,10 +1,15 @@
-"""A tornado based IPython notebook server."""
+"""A tornado based IPython notebook server.
+
+Authors:
+
+* Brian Granger
+"""
#-----------------------------------------------------------------------------
-# Copyright (C) 2011 The IPython Development Team
+# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
-# the file COPYING.txt, distributed as part of this software.
+# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
@@ -194,9 +199,9 @@ def parse_command_line(self, argv=None):
argv = sys.argv[1:]
self.kernel_argv = list(argv) # copy
- # kernel should inherit default config file from frontend
+ # Kernel should inherit default config file from frontend
self.kernel_argv.append("--KernelApp.parent_appname='%s'"%self.name)
- # scrub frontend-specific flags
+ # Scrub frontend-specific flags
for a in argv:
if a.startswith('-') and a.lstrip('-') in notebook_flags:
self.kernel_argv.remove(a)
@@ -205,7 +210,6 @@ def parse_command_line(self, argv=None):
alias = a.lstrip('-').split('=')[0]
if alias in notebook_aliases:
self.kernel_argv.remove(a)
- print self.kernel_argv
def init_configurables(self):
# Don't let Qt or ZMQ swallow KeyboardInterupts.
@@ -241,18 +245,20 @@ def initialize(self, argv=None):
self.log.critical('WARNING: the notebook server is listening on all IP addresses '
'but not using any encryption or authentication. This is highly '
'insecure and not recommended.')
- for i in range(10):
+
+ # Try random ports centered around the default.
+ from random import randint
+ n = 50 # Max number of attempts, keep reasonably large.
+ for port in [self.port] + [self.port + randint(-2*n, 2*n) for i in range(n)]:
try:
- port = self.port + i
self.http_server.listen(port, self.ip)
except socket.error, e:
if e.errno != errno.EADDRINUSE:
raise
- self.log.info('The port %i is already in use, trying: %i' % (port, port+1))
+ self.log.info('The port %i is already in use, trying another random port.' % port)
else:
self.port = port
break
-
def start(self):
ip = self.ip if self.ip else '[all ip addresses on your system]'
@@ -1,8 +1,15 @@
+"""A notebook manager that uses the local file system for storage.
+
+Authors:
+
+* Brian Granger
+"""
+
#-----------------------------------------------------------------------------
-# Copyright (C) 2011 The IPython Development Team
+# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
-# the file COPYING.txt, distributed as part of this software.
+# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
@@ -46,7 +53,7 @@ def list_notebooks(self):
dict(notebook_id=notebook,name=name)
"""
names = os.listdir(self.notebook_dir)
- names = [name.split(u'.')[0] \
+ names = [name.split(u'.')[0]
for name in names if name.endswith(self.filename_ext)]
data = []
for name in names:
@@ -76,9 +83,7 @@ def notebook_exists(self, notebook_id):
if notebook_id not in self.mapping:
return False
path = self.get_path_by_name(self.mapping[notebook_id])
- if not os.path.isfile(path):
- return False
- return True
+ return os.path.isfile(path)
def find_path(self, notebook_id):
"""Return a full path to a notebook given its notebook_id."""
Binary file not shown.
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Cell
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// CodeCell
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Kernel
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Kernel Status widget
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Layout
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// LeftPanel
@@ -1,3 +1,10 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
+
var IPython = IPython || {};
IPython.namespace = function (ns_string) {
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// On document ready
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Notebook
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// On document ready
@@ -1,6 +1,12 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
-// Cell
+// NotebookList
//============================================================================
var IPython = (function (IPython) {
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Pager
@@ -1,6 +1,12 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
-// Cell
+// PanelSection
//============================================================================
var IPython = (function (IPython) {
@@ -1,6 +1,12 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
-// Cell
+// SaveWidget
//============================================================================
var IPython = (function (IPython) {
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// TextCell
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Utilities
@@ -3,7 +3,6 @@
from unittest import TestCase
from IPython.frontend.html.notebook.kernelmanager import KernelManager
-from IPython.frontend.html.notebook.sessionmanager import SessionManagerRunningError
class TestKernelManager(TestCase):
@@ -24,16 +23,4 @@ def test_km_lifecycle(self):
self.assert_('hb_port' in port_dict)
km.get_kernel_process(kid)
- def test_session_manager(self):
- km = KernelManager()
- kid = km.start_kernel()
- sm = km.create_session_manager(kid)
- self.assert_(sm._running)
- sm.stop()
- self.assert_(not sm._running)
- sm.start()
- self.assertRaises(SessionManagerRunningError, sm.start)
- sm.get_iopub_stream()
- sm.get_shell_stream()
- sm.session
Oops, something went wrong.

0 comments on commit a661b7c

Please sign in to comment.