Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial reorg of files complete.

I have moved things around to get ready for making the notebook
a full blown app, but have not actually made it an app.  That is
next.
  • Loading branch information...
commit 02f9051eb21abe4fe424be652b6aac194708a599 1 parent a94f1fa
@ellisonbg ellisonbg authored
View
3  IPython/frontend/html/notebook/handlers.py
@@ -6,13 +6,10 @@
import uuid
from Queue import Queue
-from tornado import options
from tornado import web
from tornado import websocket
-options.define("port", default=8888, help="run on the given port", type=int)
-
_kernel_id_regex = r"(?P<kernel_id>\w+-\w+-\w+-\w+-\w+)"
_kernel_action_regex = r"(?P<action>restart|interrupt)"
View
2  IPython/frontend/html/notebook/notebookapp.py
@@ -115,7 +115,7 @@ def get_router(self, kernel_id, stream_name):
return router
-def main():
+def launch_new_instance():
options.parse_command_line()
application = NotebookApplication()
http_server = httpserver.HTTPServer(application)
View
57 IPython/frontend/html/notebook/routers.py
@@ -0,0 +1,57 @@
+import uuid
+from Queue import Queue
+
+
+class ZMQStreamRouter(object):
+
+ def __init__(self, zmq_stream):
+ self.zmq_stream = zmq_stream
+ self._clients = {}
+ self.zmq_stream.on_recv(self._on_zmq_reply)
+
+ def register_client(self, client):
+ client_id = uuid.uuid4()
+ self._clients[client_id] = client
+ return client_id
+
+ def unregister_client(self, client_id):
+ del self._clients[client_id]
+
+ def copy_clients(self, router):
+ # Copy the clients of another router.
+ for client_id, client in router._clients.items():
+ client.router = self
+ self._clients[client_id] = client
+
+
+class IOPubStreamRouter(ZMQStreamRouter):
+
+ def _on_zmq_reply(self, msg_list):
+ for client_id, client in self._clients.items():
+ for msg in msg_list:
+ client.write_message(msg)
+
+ def forward_unicode(self, client_id, msg):
+ # This is a SUB stream that we should never write to.
+ pass
+
+
+class ShellStreamRouter(ZMQStreamRouter):
+
+ def __init__(self, zmq_stream):
+ ZMQStreamRouter.__init__(self, zmq_stream)
+ self._request_queue = Queue()
+
+ def _on_zmq_reply(self, msg_list):
+ client_id = self._request_queue.get(block=False)
+ client = self._clients.get(client_id)
+ if client is not None:
+ for msg in msg_list:
+ client.write_message(msg)
+
+ def forward_unicode(self, client_id, msg):
+ self._request_queue.put(client_id)
+ self.zmq_stream.send_unicode(msg)
+
+
+
View
5 IPython/scripts/ipython-notebook
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from IPython.frontend.html.notebook import notebook
+from IPython.frontend.html.notebook import notebookapp
+
+notebookapp.launch_new_instance()
-notebook.main()
View
2  setupbase.py
@@ -282,7 +282,7 @@ def find_scripts(entry_points=False):
if entry_points:
console_scripts = [
'ipython = IPython.frontend.terminal.ipapp:launch_new_instance',
- 'ipython-notebook = IPython.frontend.html.notebook.notebook:main',
+ 'ipython-notebook = IPython.frontend.html.notebook.notebookapp:launch_new_instance',
'pycolor = IPython.utils.PyColorize:main',
'ipcontroller = IPython.parallel.apps.ipcontrollerapp:launch_new_instance',
'ipengine = IPython.parallel.apps.ipengineapp:launch_new_instance',
Please sign in to comment.
Something went wrong with that request. Please try again.