Show More
@@ -193,6 +193,15 b' class ProfileCreate(BaseIPythonApplication):' | |||||
193 | pass |
|
193 | pass | |
194 | else: |
|
194 | else: | |
195 | apps.append(IPythonQtConsoleApp) |
|
195 | apps.append(IPythonQtConsoleApp) | |
|
196 | try: | |||
|
197 | from IPython.frontend.html.notebook.notebookapp import IPythonNotebookApp | |||
|
198 | except Exception: | |||
|
199 | # this should be ImportError, but under weird circumstances | |||
|
200 | # this might be an AttributeError, or possibly others | |||
|
201 | # in any case, nothing should cause the profile creation to crash. | |||
|
202 | pass | |||
|
203 | else: | |||
|
204 | apps.append(IPythonNotebookApp) | |||
196 | if self.parallel: |
|
205 | if self.parallel: | |
197 | from IPython.parallel.apps.ipcontrollerapp import IPControllerApp |
|
206 | from IPython.parallel.apps.ipcontrollerapp import IPControllerApp | |
198 | from IPython.parallel.apps.ipengineapp import IPEngineApp |
|
207 | from IPython.parallel.apps.ipengineapp import IPEngineApp |
@@ -38,7 +38,6 b' from .notebookmanager import NotebookManager' | |||||
38 |
|
38 | |||
39 | from IPython.core.application import BaseIPythonApplication |
|
39 | from IPython.core.application import BaseIPythonApplication | |
40 | from IPython.core.profiledir import ProfileDir |
|
40 | from IPython.core.profiledir import ProfileDir | |
41 | from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget |
|
|||
42 | from IPython.zmq.session import Session |
|
41 | from IPython.zmq.session import Session | |
43 | from IPython.zmq.zmqshell import ZMQInteractiveShell |
|
42 | from IPython.zmq.zmqshell import ZMQInteractiveShell | |
44 | from IPython.zmq.ipkernel import ( |
|
43 | from IPython.zmq.ipkernel import ( | |
@@ -58,6 +57,14 b' _notebook_id_regex = r"(?P<notebook_id>\\w+-\\w+-\\w+-\\w+-\\w+)"' | |||||
58 |
|
57 | |||
59 | LOCALHOST = '127.0.0.1' |
|
58 | LOCALHOST = '127.0.0.1' | |
60 |
|
59 | |||
|
60 | _examples = """ | |||
|
61 | ipython notebook # start the notebook | |||
|
62 | ipython notebook --profile=sympy # use the sympy profile | |||
|
63 | ipython notebook --pylab=inline # pylab in inline plotting mode | |||
|
64 | ipython notebook --certfile=mycert.pem # use SSL/TLS certificate | |||
|
65 | ipython notebook --port=5555 --ip=* # Listen on port 5555, all interfaces | |||
|
66 | """ | |||
|
67 | ||||
61 | #----------------------------------------------------------------------------- |
|
68 | #----------------------------------------------------------------------------- | |
62 | # The Tornado web application |
|
69 | # The Tornado web application | |
63 | #----------------------------------------------------------------------------- |
|
70 | #----------------------------------------------------------------------------- | |
@@ -102,17 +109,21 b' notebook_flags = []' | |||||
102 |
|
109 | |||
103 | aliases = dict(ipkernel_aliases) |
|
110 | aliases = dict(ipkernel_aliases) | |
104 |
|
111 | |||
105 |
aliases.update( |
|
112 | aliases.update({ | |
106 |
ip |
|
113 | 'ip': 'IPythonNotebookApp.ip', | |
107 |
port |
|
114 | 'port': 'IPythonNotebookApp.port', | |
108 | colors = 'ZMQInteractiveShell.colors', |
|
115 | 'keyfile': 'IPythonNotebookApp.keyfile', | |
109 | )) |
|
116 | 'certfile': 'IPythonNotebookApp.certfile', | |
|
117 | 'colors': 'ZMQInteractiveShell.colors', | |||
|
118 | 'notebook-dir': 'NotebookManager.notebook_dir' | |||
|
119 | }) | |||
110 |
|
120 | |||
111 | #----------------------------------------------------------------------------- |
|
121 | #----------------------------------------------------------------------------- | |
112 | # IPythonNotebookApp |
|
122 | # IPythonNotebookApp | |
113 | #----------------------------------------------------------------------------- |
|
123 | #----------------------------------------------------------------------------- | |
114 |
|
124 | |||
115 | class IPythonNotebookApp(BaseIPythonApplication): |
|
125 | class IPythonNotebookApp(BaseIPythonApplication): | |
|
126 | ||||
116 | name = 'ipython-notebook' |
|
127 | name = 'ipython-notebook' | |
117 | default_config_file_name='ipython_notebook_config.py' |
|
128 | default_config_file_name='ipython_notebook_config.py' | |
118 |
|
129 | |||
@@ -122,6 +133,7 b' class IPythonNotebookApp(BaseIPythonApplication):' | |||||
122 | This launches a Tornado based HTML Notebook Server that serves up an |
|
133 | This launches a Tornado based HTML Notebook Server that serves up an | |
123 | HTML5/Javascript Notebook client. |
|
134 | HTML5/Javascript Notebook client. | |
124 | """ |
|
135 | """ | |
|
136 | examples = _examples | |||
125 |
|
137 | |||
126 | classes = [IPKernelApp, ZMQInteractiveShell, ProfileDir, Session, |
|
138 | classes = [IPKernelApp, ZMQInteractiveShell, ProfileDir, Session, | |
127 | RoutingKernelManager, NotebookManager, |
|
139 | RoutingKernelManager, NotebookManager, | |
@@ -136,17 +148,26 b' class IPythonNotebookApp(BaseIPythonApplication):' | |||||
136 | config=True, |
|
148 | config=True, | |
137 | help="Set the log level by value or name.") |
|
149 | help="Set the log level by value or name.") | |
138 |
|
150 | |||
139 | # connection info: |
|
151 | # Network related information. | |
|
152 | ||||
140 | ip = Unicode(LOCALHOST, config=True, |
|
153 | ip = Unicode(LOCALHOST, config=True, | |
141 | help="The IP address the notebook server will listen on." |
|
154 | help="The IP address the notebook server will listen on." | |
142 | ) |
|
155 | ) | |
143 |
|
156 | |||
|
157 | def _ip_changed(self, name, old, new): | |||
|
158 | if new == u'*': self.ip = u'' | |||
|
159 | ||||
144 | port = Int(8888, config=True, |
|
160 | port = Int(8888, config=True, | |
145 | help="The port the notebook server will listen on." |
|
161 | help="The port the notebook server will listen on." | |
146 | ) |
|
162 | ) | |
147 |
|
163 | |||
148 | # the factory for creating a widget |
|
164 | certfile = Unicode(u'', config=True, | |
149 | widget_factory = Any(RichIPythonWidget) |
|
165 | help="""The full path to an SSL/TLS certificate file.""" | |
|
166 | ) | |||
|
167 | ||||
|
168 | keyfile = Unicode(u'', config=True, | |||
|
169 | help="""The full path to a private key file for usage with SSL/TLS.""" | |||
|
170 | ) | |||
150 |
|
171 | |||
151 | def parse_command_line(self, argv=None): |
|
172 | def parse_command_line(self, argv=None): | |
152 | super(IPythonNotebookApp, self).parse_command_line(argv) |
|
173 | super(IPythonNotebookApp, self).parse_command_line(argv) | |
@@ -185,11 +206,22 b' class IPythonNotebookApp(BaseIPythonApplication):' | |||||
185 | self.web_app = NotebookWebApplication( |
|
206 | self.web_app = NotebookWebApplication( | |
186 | self.routing_kernel_manager, self.notebook_manager, self.log |
|
207 | self.routing_kernel_manager, self.notebook_manager, self.log | |
187 | ) |
|
208 | ) | |
188 | self.http_server = httpserver.HTTPServer(self.web_app) |
|
209 | if self.certfile: | |
189 | self.http_server.listen(self.port) |
|
210 | ssl_options = dict(certfile=self.certfile) | |
|
211 | if self.keyfile: | |||
|
212 | ssl_options['keyfile'] = self.keyfile | |||
|
213 | else: | |||
|
214 | ssl_options = None | |||
|
215 | self.http_server = httpserver.HTTPServer(self.web_app, ssl_options=ssl_options) | |||
|
216 | if ssl_options is None and not self.ip: | |||
|
217 | self.log.critical('WARNING: the notebook server is listening on all IP addresses ' | |||
|
218 | 'but not using any encryption or authentication. This is highly ' | |||
|
219 | 'insecure and not recommended.') | |||
|
220 | self.http_server.listen(self.port, self.ip) | |||
190 |
|
221 | |||
191 | def start(self): |
|
222 | def start(self): | |
192 | self.log.info("The IPython Notebook is running at: http://%s:%i" % (self.ip, self.port)) |
|
223 | ip = self.ip if self.ip else '[all ip addresses on your system]' | |
|
224 | self.log.info("The IPython Notebook is running at: http://%s:%i" % (ip, self.port)) | |||
193 | ioloop.IOLoop.instance().start() |
|
225 | ioloop.IOLoop.instance().start() | |
194 |
|
226 | |||
195 | #----------------------------------------------------------------------------- |
|
227 | #----------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now