Show More
@@ -35,6 +35,7 b' from IPython.core.profiledir import ProfileDir' | |||||
35 | from IPython.kernel.blocking import BlockingKernelClient |
|
35 | from IPython.kernel.blocking import BlockingKernelClient | |
36 | from IPython.kernel import KernelManager |
|
36 | from IPython.kernel import KernelManager | |
37 | from IPython.kernel import tunnel_to_kernel, find_connection_file, swallow_argv |
|
37 | from IPython.kernel import tunnel_to_kernel, find_connection_file, swallow_argv | |
|
38 | from IPython.kernel.kernelspec import NoSuchKernel | |||
38 | from IPython.utils.path import filefind |
|
39 | from IPython.utils.path import filefind | |
39 | from IPython.utils.py3compat import str_to_bytes |
|
40 | from IPython.utils.py3compat import str_to_bytes | |
40 | from IPython.utils.traitlets import ( |
|
41 | from IPython.utils.traitlets import ( | |
@@ -331,18 +332,23 b' class IPythonConsoleApp(ConnectionFileMixin):' | |||||
331 | signal.signal(signal.SIGINT, signal.SIG_DFL) |
|
332 | signal.signal(signal.SIGINT, signal.SIG_DFL) | |
332 |
|
333 | |||
333 | # Create a KernelManager and start a kernel. |
|
334 | # Create a KernelManager and start a kernel. | |
334 | self.kernel_manager = self.kernel_manager_class( |
|
335 | try: | |
335 | ip=self.ip, |
|
336 | self.kernel_manager = self.kernel_manager_class( | |
336 |
|
|
337 | ip=self.ip, | |
337 |
s |
|
338 | transport=self.transport, | |
338 |
|
|
339 | shell_port=self.shell_port, | |
339 |
|
|
340 | iopub_port=self.iopub_port, | |
340 |
|
|
341 | stdin_port=self.stdin_port, | |
341 |
|
|
342 | hb_port=self.hb_port, | |
342 |
|
|
343 | connection_file=self.connection_file, | |
343 |
|
|
344 | kernel_name=self.kernel_name, | |
344 |
|
|
345 | parent=self, | |
345 | ) |
|
346 | ipython_dir=self.ipython_dir, | |
|
347 | ) | |||
|
348 | except NoSuchKernel: | |||
|
349 | self.log.critical("Could not find kernel %s", self.kernel_name) | |||
|
350 | self.exit(1) | |||
|
351 | ||||
346 | self.kernel_manager.client_factory = self.kernel_client_class |
|
352 | self.kernel_manager.client_factory = self.kernel_client_class | |
347 | self.kernel_manager.start_kernel(extra_arguments=self.kernel_argv) |
|
353 | self.kernel_manager.start_kernel(extra_arguments=self.kernel_argv) | |
348 | atexit.register(self.kernel_manager.cleanup_ipc_files) |
|
354 | atexit.register(self.kernel_manager.cleanup_ipc_files) |
@@ -62,6 +62,10 b' def _list_kernels_in(dir):' | |||||
62 | return {f.lower(): pjoin(dir, f) for f in os.listdir(dir) |
|
62 | return {f.lower(): pjoin(dir, f) for f in os.listdir(dir) | |
63 | if _is_kernel_dir(pjoin(dir, f))} |
|
63 | if _is_kernel_dir(pjoin(dir, f))} | |
64 |
|
64 | |||
|
65 | class NoSuchKernel(KeyError): | |||
|
66 | def __init__(self, name): | |||
|
67 | self.name = name | |||
|
68 | ||||
65 | class KernelSpecManager(HasTraits): |
|
69 | class KernelSpecManager(HasTraits): | |
66 | ipython_dir = Unicode() |
|
70 | ipython_dir = Unicode() | |
67 | def _ipython_dir_default(self): |
|
71 | def _ipython_dir_default(self): | |
@@ -115,12 +119,15 b' class KernelSpecManager(HasTraits):' | |||||
115 | def get_kernel_spec(self, kernel_name): |
|
119 | def get_kernel_spec(self, kernel_name): | |
116 | """Returns a :class:`KernelSpec` instance for the given kernel_name. |
|
120 | """Returns a :class:`KernelSpec` instance for the given kernel_name. | |
117 |
|
121 | |||
118 |
Raises |
|
122 | Raises :exc:`NoSuchKernel` if the given kernel name is not found. | |
119 | """ |
|
123 | """ | |
120 | if kernel_name == 'python': |
|
124 | if kernel_name == 'python': | |
121 | kernel_name = NATIVE_KERNEL_NAME |
|
125 | kernel_name = NATIVE_KERNEL_NAME | |
122 | d = self.find_kernel_specs() |
|
126 | d = self.find_kernel_specs() | |
123 | resource_dir = d[kernel_name.lower()] |
|
127 | try: | |
|
128 | resource_dir = d[kernel_name.lower()] | |||
|
129 | except KeyError: | |||
|
130 | raise NoSuchKernel(kernel_name) | |||
124 | return KernelSpec.from_resource_dir(resource_dir) |
|
131 | return KernelSpec.from_resource_dir(resource_dir) | |
125 |
|
132 | |||
126 | def find_kernel_specs(): |
|
133 | def find_kernel_specs(): |
General Comments 0
You need to be logged in to leave comments.
Login now