Show More
@@ -23,7 +23,7 b' from zmq.utils import jsonapi' | |||
|
23 | 23 | |
|
24 | 24 | from IPython.utils.jsonutil import date_default |
|
25 | 25 | |
|
26 | from ...base.handlers import IPythonHandler | |
|
26 | from ...base.handlers import IPythonHandler, json_errors | |
|
27 | 27 | from ...base.zmqhandlers import AuthenticatedZMQStreamHandler |
|
28 | 28 | |
|
29 | 29 | #----------------------------------------------------------------------------- |
@@ -34,11 +34,13 b' from ...base.zmqhandlers import AuthenticatedZMQStreamHandler' | |||
|
34 | 34 | class MainKernelHandler(IPythonHandler): |
|
35 | 35 | |
|
36 | 36 | @web.authenticated |
|
37 | @json_errors | |
|
37 | 38 | def get(self): |
|
38 | 39 | km = self.kernel_manager |
|
39 | self.finish(jsonapi.dumps(km.list_kernels())) | |
|
40 | self.finish(jsonapi.dumps(km.list_kernels(self.ws_url))) | |
|
40 | 41 | |
|
41 | 42 | @web.authenticated |
|
43 | @json_errors | |
|
42 | 44 | def post(self): |
|
43 | 45 | km = self.kernel_manager |
|
44 | 46 | kernel_id = km.start_kernel() |
@@ -52,12 +54,14 b' class KernelHandler(IPythonHandler):' | |||
|
52 | 54 | SUPPORTED_METHODS = ('DELETE', 'GET') |
|
53 | 55 | |
|
54 | 56 | @web.authenticated |
|
57 | @json_errors | |
|
55 | 58 | def get(self, kernel_id): |
|
56 | 59 | km = self.kernel_manager |
|
57 | 60 | model = km.kernel_model(kernel_id, self.ws_url) |
|
58 | 61 | self.finish(jsonapi.dumps(model)) |
|
59 | 62 | |
|
60 | 63 | @web.authenticated |
|
64 | @json_errors | |
|
61 | 65 | def delete(self, kernel_id): |
|
62 | 66 | km = self.kernel_manager |
|
63 | 67 | km.shutdown_kernel(kernel_id) |
@@ -68,6 +72,7 b' class KernelHandler(IPythonHandler):' | |||
|
68 | 72 | class KernelActionHandler(IPythonHandler): |
|
69 | 73 | |
|
70 | 74 | @web.authenticated |
|
75 | @json_errors | |
|
71 | 76 | def post(self, kernel_id, action): |
|
72 | 77 | km = self.kernel_manager |
|
73 | 78 | if action == 'interrupt': |
@@ -79,9 +79,14 b' class MappingKernelManager(MultiKernelManager):' | |||
|
79 | 79 | model = {"id":kernel_id, "ws_url": ws_url} |
|
80 | 80 | return model |
|
81 | 81 | |
|
82 | def list_kernels(self): | |
|
82 | def list_kernels(self, ws_url): | |
|
83 | 83 | """Returns a list of kernel_id's of kernels running.""" |
|
84 | return super(MappingKernelManager, self).list_kernel_ids() | |
|
84 | kernels = [] | |
|
85 | kernel_ids = super(MappingKernelManager, self).list_kernel_ids() | |
|
86 | for kernel_id in kernel_ids: | |
|
87 | model = self.kernel_model(kernel_id, ws_url) | |
|
88 | kernels.append(model) | |
|
89 | return kernels | |
|
85 | 90 | |
|
86 | 91 | # override _check_kernel_id to raise 404 instead of KeyError |
|
87 | 92 | def _check_kernel_id(self, kernel_id): |
@@ -36,7 +36,7 b' class KernelAPITest(NotebookTestBase):' | |||
|
36 | 36 | # GET request |
|
37 | 37 | r = requests.get(self.base_url()) |
|
38 | 38 | assert isinstance(r.json(), list) |
|
39 | self.assertEqual(r.json()[0], data['id']) | |
|
39 | self.assertEqual(r.json()[0]['id'], data['id']) | |
|
40 | 40 | |
|
41 | 41 | def test_kernel_handler(self): |
|
42 | 42 | # GET kernel with id |
@@ -228,8 +228,8 b' class FileNotebookManager(NotebookManager):' | |||
|
228 | 228 | self.log.debug("Unlinking checkpoint %s", cp_path) |
|
229 | 229 | os.unlink(cp_path) |
|
230 | 230 | |
|
231 |
self.log.debug("Unlinking notebook %s", |
|
|
232 |
os.unlink( |
|
|
231 | self.log.debug("Unlinking notebook %s", os_path) | |
|
232 | os.unlink(os_path) | |
|
233 | 233 | |
|
234 | 234 | def rename_notebook(self, old_name, old_path, new_name, new_path): |
|
235 | 235 | """Rename a notebook.""" |
General Comments 0
You need to be logged in to leave comments.
Login now