diff --git a/IPython/html/services/kernels/handlers.py b/IPython/html/services/kernels/handlers.py index 693e05a..147e2a7 100644 --- a/IPython/html/services/kernels/handlers.py +++ b/IPython/html/services/kernels/handlers.py @@ -23,7 +23,7 @@ from zmq.utils import jsonapi from IPython.utils.jsonutil import date_default -from ...base.handlers import IPythonHandler +from ...base.handlers import IPythonHandler, json_errors from ...base.zmqhandlers import AuthenticatedZMQStreamHandler #----------------------------------------------------------------------------- @@ -34,11 +34,13 @@ from ...base.zmqhandlers import AuthenticatedZMQStreamHandler class MainKernelHandler(IPythonHandler): @web.authenticated + @json_errors def get(self): km = self.kernel_manager - self.finish(jsonapi.dumps(km.list_kernels())) + self.finish(jsonapi.dumps(km.list_kernels(self.ws_url))) @web.authenticated + @json_errors def post(self): km = self.kernel_manager kernel_id = km.start_kernel() @@ -52,12 +54,14 @@ class KernelHandler(IPythonHandler): SUPPORTED_METHODS = ('DELETE', 'GET') @web.authenticated + @json_errors def get(self, kernel_id): km = self.kernel_manager model = km.kernel_model(kernel_id, self.ws_url) self.finish(jsonapi.dumps(model)) @web.authenticated + @json_errors def delete(self, kernel_id): km = self.kernel_manager km.shutdown_kernel(kernel_id) @@ -68,6 +72,7 @@ class KernelHandler(IPythonHandler): class KernelActionHandler(IPythonHandler): @web.authenticated + @json_errors def post(self, kernel_id, action): km = self.kernel_manager if action == 'interrupt': diff --git a/IPython/html/services/kernels/kernelmanager.py b/IPython/html/services/kernels/kernelmanager.py index 8535d3f..787abd1 100644 --- a/IPython/html/services/kernels/kernelmanager.py +++ b/IPython/html/services/kernels/kernelmanager.py @@ -79,9 +79,14 @@ class MappingKernelManager(MultiKernelManager): model = {"id":kernel_id, "ws_url": ws_url} return model - def list_kernels(self): + def list_kernels(self, ws_url): """Returns a list of kernel_id's of kernels running.""" - return super(MappingKernelManager, self).list_kernel_ids() + kernels = [] + kernel_ids = super(MappingKernelManager, self).list_kernel_ids() + for kernel_id in kernel_ids: + model = self.kernel_model(kernel_id, ws_url) + kernels.append(model) + return kernels # override _check_kernel_id to raise 404 instead of KeyError def _check_kernel_id(self, kernel_id): diff --git a/IPython/html/services/kernels/tests/test_kernels_api.py b/IPython/html/services/kernels/tests/test_kernels_api.py index 707bdf1..894717f 100644 --- a/IPython/html/services/kernels/tests/test_kernels_api.py +++ b/IPython/html/services/kernels/tests/test_kernels_api.py @@ -36,7 +36,7 @@ class KernelAPITest(NotebookTestBase): # GET request r = requests.get(self.base_url()) assert isinstance(r.json(), list) - self.assertEqual(r.json()[0], data['id']) + self.assertEqual(r.json()[0]['id'], data['id']) def test_kernel_handler(self): # GET kernel with id diff --git a/IPython/html/services/notebooks/filenbmanager.py b/IPython/html/services/notebooks/filenbmanager.py index e7d0d08..bbf2d85 100644 --- a/IPython/html/services/notebooks/filenbmanager.py +++ b/IPython/html/services/notebooks/filenbmanager.py @@ -228,8 +228,8 @@ class FileNotebookManager(NotebookManager): self.log.debug("Unlinking checkpoint %s", cp_path) os.unlink(cp_path) - self.log.debug("Unlinking notebook %s", nb_path) - os.unlink(nb_path) + self.log.debug("Unlinking notebook %s", os_path) + os.unlink(os_path) def rename_notebook(self, old_name, old_path, new_name, new_path): """Rename a notebook."""