diff --git a/IPython/__init__.py b/IPython/__init__.py index d784eb6..0252940 100644 --- a/IPython/__init__.py +++ b/IPython/__init__.py @@ -43,14 +43,6 @@ sys.path.append(os.path.join(os.path.dirname(__file__), "extensions")) 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 diff --git a/IPython/core/magic.py b/IPython/core/magic.py index 20ac4e3..7a794a9 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -48,8 +48,7 @@ from IPython.core.error import UsageError 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 diff --git a/IPython/core/profileapp.py b/IPython/core/profileapp.py index 52ef639..f56526a 100644 --- a/IPython/core/profileapp.py +++ b/IPython/core/profileapp.py @@ -195,11 +195,12 @@ class ProfileCreate(BaseIPythonApplication): 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: diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py index 1d96cd9..93d0568 100644 --- a/IPython/frontend/html/notebook/handlers.py +++ b/IPython/frontend/html/notebook/handlers.py @@ -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 diff --git a/IPython/frontend/html/notebook/kernelmanager.py b/IPython/frontend/html/notebook/kernelmanager.py index 89bca69..355d147 100644 --- a/IPython/frontend/html/notebook/kernelmanager.py +++ b/IPython/frontend/html/notebook/kernelmanager.py @@ -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. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py index 728a076..c3a3d0f 100644 --- a/IPython/frontend/html/notebook/notebookapp.py +++ b/IPython/frontend/html/notebook/notebookapp.py @@ -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 @@ class IPythonNotebookApp(BaseIPythonApplication): 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 @@ class IPythonNotebookApp(BaseIPythonApplication): 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 @@ class IPythonNotebookApp(BaseIPythonApplication): 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]' diff --git a/IPython/frontend/html/notebook/notebookmanager.py b/IPython/frontend/html/notebook/notebookmanager.py index 2cc56cb..e941771 100644 --- a/IPython/frontend/html/notebook/notebookmanager.py +++ b/IPython/frontend/html/notebook/notebookmanager.py @@ -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 @@ class NotebookManager(LoggingConfigurable): 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 @@ class NotebookManager(LoggingConfigurable): 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.""" diff --git a/IPython/frontend/html/notebook/static/favicon.ico b/IPython/frontend/html/notebook/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..4e323758171fc7a2fd6eb358f9b0db255530d2e0 GIT binary patch literal 1430 zc$~GAT}YEr7{|}MP3GnrHdif+oVl-%KBx;Jv4u!UA4C_0&{cL}lp~1<`k>ycWkDfI zYbgm*!653Q52GCUQhQq?SPZFTNLtY(Ms2S-+PklR#}&JJ4QA_ic+SQDInSSS9v%)M z3|%@Mp}Uc=WrQpxgxF|MiI~W5{eQwRjHX0ZGQJ3gy&T`u>*fbsy*&5y0abi?-RJZ1 zD1v*T&(JKkLBB`^_sKS75?_lcFYqlPA`lu!{Z0prY8k>@e<3%>O{22fiW^6oFe8en z-FphVELz0F(pOFAayWSL5eTD%tHTat6M6l*Hv+kK1+KMkf{+xkWczV6S2Ku>KbQ2G zPNbo4I0QLiV7KTnJN05-pC$u?3IBaWqfrR4@5p6S`LpyY7zjkb$g8lYr4jl{1NfU~ z=Q5H$6>@?#=2~o6zYbd)8_<9LD3U@1GwB>!I9c*yhD{-m>6jC>TJC^zH4 z788#34MC|;!S8m^H)h}(c?XqhB|PjtNuSNj7>teH!Ni9tT)4|aR#t`1*0mUW8-)KQ zkCgBw-;>yE3Va}hPvM}XkDB(!T33VBW-AnGEtXd(@#@w&TAH4Bw%$zsK=