Permalink
Browse files

Fix the kernelmanager so that running it from arbitrary paths work

  • Loading branch information...
jamesgao committed Oct 15, 2010
1 parent 30d7333 commit 7fe119b80046a8bdf903edaf4a6499aeea2d385d
Showing with 5 additions and 2 deletions.
  1. +5 −2 IPython/frontend/html/kernelmanager.py
@@ -8,6 +8,7 @@
import Queue
import threading
import mimetypes
+import __main__
from string import Template
from SocketServer import ThreadingMixIn
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
@@ -54,6 +55,8 @@ def addreq(self, msg):
manager = CometManager()
+basepath = os.path.split(__main__.__file__)[0]+"/"
+
class IPyHttpHandler(BaseHTTPRequestHandler):
def do_GET(self):
#Path is either a real path, or the client_id
@@ -73,7 +76,7 @@ def do_GET(self):
#This is a good spot to add login mechanics
client_id = str(time.time())
manager.register(client_id)
- page_text = Template(open("notebook.html").read())
+ page_text = Template(open(basepath + "notebook.html").read())
self.wfile.write(page_text.safe_substitute(client_id = client_id))
elif os.path.exists(path):
@@ -82,7 +85,7 @@ def do_GET(self):
self.send_header("Content-type", mime)
self.end_headers()
- self.wfile.write(open(path).read())
+ self.wfile.write(open(basepath + path).read())
else:
self.send_response(404)
self.end_headers()

0 comments on commit 7fe119b

Please sign in to comment.