13
13
pjoin = os .path .join
14
14
15
15
from ipython_genutils .py3compat import PY3
16
- from traitlets import HasTraits , List , Unicode , Dict , Set , Bool , Type
16
+ from traitlets import (
17
+ HasTraits , List , Unicode , Dict , Set , Bool , Type , CaselessStrEnum
18
+ )
17
19
from traitlets .config import LoggingConfigurable
18
20
19
21
from jupyter_core .paths import jupyter_data_dir , jupyter_path , SYSTEM_JUPYTER_PATH
@@ -28,6 +30,9 @@ class KernelSpec(HasTraits):
28
30
language = Unicode ()
29
31
env = Dict ()
30
32
resource_dir = Unicode ()
33
+ interrupt_mode = CaselessStrEnum (
34
+ ['message' , 'signal' ], default_value = 'signal'
35
+ )
31
36
metadata = Dict ()
32
37
33
38
@classmethod
@@ -46,6 +51,7 @@ def to_dict(self):
46
51
env = self .env ,
47
52
display_name = self .display_name ,
48
53
language = self .language ,
54
+ interrupt_mode = self .interrupt_mode ,
49
55
metadata = self .metadata ,
50
56
)
51
57
@@ -227,7 +233,7 @@ def get_all_specs(self):
227
233
228
234
def remove_kernel_spec (self , name ):
229
235
"""Remove a kernel spec directory by name.
230
-
236
+
231
237
Returns the path that was deleted.
232
238
"""
233
239
save_native = self .ensure_native_kernel
@@ -263,7 +269,7 @@ def install_kernel_spec(self, source_dir, kernel_name=None, user=False,
263
269
If ``user`` is False, it will attempt to install into the systemwide
264
270
kernel registry. If the process does not have appropriate permissions,
265
271
an :exc:`OSError` will be raised.
266
-
272
+
267
273
If ``prefix`` is given, the kernelspec will be installed to
268
274
PREFIX/share/jupyter/kernels/KERNEL_NAME. This can be sys.prefix
269
275
for installation inside virtual or conda envs.
@@ -284,16 +290,16 @@ def install_kernel_spec(self, source_dir, kernel_name=None, user=False,
284
290
DeprecationWarning ,
285
291
stacklevel = 2 ,
286
292
)
287
-
293
+
288
294
destination = self ._get_destination_dir (kernel_name , user = user , prefix = prefix )
289
295
self .log .debug ('Installing kernelspec in %s' , destination )
290
-
296
+
291
297
kernel_dir = os .path .dirname (destination )
292
298
if kernel_dir not in self .kernel_dirs :
293
299
self .log .warning ("Installing to %s, which is not in %s. The kernelspec may not be found." ,
294
300
kernel_dir , self .kernel_dirs ,
295
301
)
296
-
302
+
297
303
if os .path .isdir (destination ):
298
304
self .log .info ('Removing existing kernelspec in %s' , destination )
299
305
shutil .rmtree (destination )
0 commit comments