Show More
@@ -40,7 +40,7 b' class MappingKernelManager(MultiKernelManager):' | |||||
40 | return "IPython.kernel.ioloop.IOLoopKernelManager" |
|
40 | return "IPython.kernel.ioloop.IOLoopKernelManager" | |
41 |
|
41 | |||
42 | kernel_argv = List(Unicode) |
|
42 | kernel_argv = List(Unicode) | |
43 |
|
43 | |||
44 | root_dir = Unicode(getcwd(), config=True) |
|
44 | root_dir = Unicode(getcwd(), config=True) | |
45 |
|
45 | |||
46 | def _root_dir_changed(self, name, old, new): |
|
46 | def _root_dir_changed(self, name, old, new): | |
@@ -60,9 +60,13 b' class MappingKernelManager(MultiKernelManager):' | |||||
60 | """notice that a kernel died""" |
|
60 | """notice that a kernel died""" | |
61 | self.log.warn("Kernel %s died, removing from map.", kernel_id) |
|
61 | self.log.warn("Kernel %s died, removing from map.", kernel_id) | |
62 | self.remove_kernel(kernel_id) |
|
62 | self.remove_kernel(kernel_id) | |
63 |
|
63 | |||
64 | def cwd_for_path(self, path): |
|
64 | def cwd_for_path(self, path): | |
65 | """Turn API path into absolute OS path.""" |
|
65 | """Turn API path into absolute OS path.""" | |
|
66 | # short circuit for NotebookManagers that pass in absolute paths | |||
|
67 | if os.path.exists(path): | |||
|
68 | return path | |||
|
69 | ||||
66 | os_path = to_os_path(path, self.root_dir) |
|
70 | os_path = to_os_path(path, self.root_dir) | |
67 | # in the case of notebooks and kernels not being on the same filesystem, |
|
71 | # in the case of notebooks and kernels not being on the same filesystem, | |
68 | # walk up to root_dir if the paths don't exist |
|
72 | # walk up to root_dir if the paths don't exist | |
@@ -77,7 +81,7 b' class MappingKernelManager(MultiKernelManager):' | |||||
77 | ---------- |
|
81 | ---------- | |
78 | kernel_id : uuid |
|
82 | kernel_id : uuid | |
79 | The uuid to associate the new kernel with. If this |
|
83 | The uuid to associate the new kernel with. If this | |
80 |
is not None, this kernel will be persistent whenever it is |
|
84 | is not None, this kernel will be persistent whenever it is | |
81 | requested. |
|
85 | requested. | |
82 | path : API path |
|
86 | path : API path | |
83 | The API path (unicode, '/' delimited) for the cwd. |
|
87 | The API path (unicode, '/' delimited) for the cwd. |
@@ -492,3 +492,7 b' class FileNotebookManager(NotebookManager):' | |||||
492 |
|
492 | |||
493 | def info_string(self): |
|
493 | def info_string(self): | |
494 | return "Serving notebooks from local directory: %s" % self.notebook_dir |
|
494 | return "Serving notebooks from local directory: %s" % self.notebook_dir | |
|
495 | ||||
|
496 | def get_kernel_path(self, name, path='', model=None): | |||
|
497 | """ Return the path to start kernel in """ | |||
|
498 | return os.path.join(self.notebook_dir, path) |
@@ -168,6 +168,10 b' class NotebookManager(LoggingConfigurable):' | |||||
168 | # NotebookManager API part 2: methods that have useable default |
|
168 | # NotebookManager API part 2: methods that have useable default | |
169 | # implementations, but can be overridden in subclasses. |
|
169 | # implementations, but can be overridden in subclasses. | |
170 |
|
170 | |||
|
171 | def get_kernel_path(self, name, path='', model=None): | |||
|
172 | """ Return the path to start kernel in """ | |||
|
173 | return path | |||
|
174 | ||||
171 | def increment_filename(self, basename, path=''): |
|
175 | def increment_filename(self, basename, path=''): | |
172 | """Increment a notebook filename without the .ipynb to make it unique. |
|
176 | """Increment a notebook filename without the .ipynb to make it unique. | |
173 |
|
177 |
@@ -42,7 +42,7 b' class SessionRootHandler(IPythonHandler):' | |||||
42 | @web.authenticated |
|
42 | @web.authenticated | |
43 | @json_errors |
|
43 | @json_errors | |
44 | def post(self): |
|
44 | def post(self): | |
45 |
# Creates a new session |
|
45 | # Creates a new session | |
46 | #(unless a session already exists for the named nb) |
|
46 | #(unless a session already exists for the named nb) | |
47 | sm = self.session_manager |
|
47 | sm = self.session_manager | |
48 | nbm = self.notebook_manager |
|
48 | nbm = self.notebook_manager | |
@@ -62,7 +62,9 b' class SessionRootHandler(IPythonHandler):' | |||||
62 | if sm.session_exists(name=name, path=path): |
|
62 | if sm.session_exists(name=name, path=path): | |
63 | model = sm.get_session(name=name, path=path) |
|
63 | model = sm.get_session(name=name, path=path) | |
64 | else: |
|
64 | else: | |
65 | kernel_id = km.start_kernel(path=path) |
|
65 | # allow nbm to specify kernels cwd | |
|
66 | kernel_path = nbm.get_kernel_path(name=name, path=path) | |||
|
67 | kernel_id = km.start_kernel(path=kernel_path) | |||
66 | model = sm.create_session(name=name, path=path, kernel_id=kernel_id) |
|
68 | model = sm.create_session(name=name, path=path, kernel_id=kernel_id) | |
67 | location = url_path_join(self.base_url, 'api', 'sessions', model['id']) |
|
69 | location = url_path_join(self.base_url, 'api', 'sessions', model['id']) | |
68 | self.set_header('Location', url_escape(location)) |
|
70 | self.set_header('Location', url_escape(location)) |
General Comments 0
You need to be logged in to leave comments.
Login now