##// END OF EJS Templates
Initial support for supplying kernel logos in kernel spec
Thomas Kluyver -
Show More
1 NO CONTENT: new file 100644, binary diff hidden
@@ -85,6 +85,7 b' define(['
85 85 this.events.on('spec_changed.Kernel', function(event, data) {
86 86 that.current_selection = data.name;
87 87 that.element.find("#current_kernel_spec").find('.kernel_name').text(data.display_name);
88 that.element.find("#current_kernel_logo").attr("src", "/kernelspecs/"+data.name+"/logo-32.png");
88 89 });
89 90
90 91 this.events.on('kernel_created.Session', function(event, data) {
@@ -42,6 +42,7 b' class="notebook_app"'
42 42 </span>
43 43
44 44 <span id="kernel_selector_widget" class="pull-right dropdown">
45 <img id="current_kernel_logo" src="/kernelspecs/python/logo-32.png"/>
45 46 <button class="dropdown-toggle btn btn-sm navbar-btn" data-toggle="dropdown" type='button' id="current_kernel_spec">
46 47 <span class='kernel_name'>Kernel</span>
47 48 <span class="caret"></span>
@@ -109,8 +109,7 b' class KernelSpecManager(HasTraits):'
109 109
110 110 @property
111 111 def _native_kernel_resource_dir(self):
112 # TODO: This may be different when we actually have any resources
113 return os.path.dirname(__file__)
112 return pjoin(os.path.dirname(__file__), 'resources')
114 113
115 114 def find_kernel_specs(self):
116 115 """Returns a dict mapping kernel names to resource directories."""
@@ -128,7 +127,8 b' class KernelSpecManager(HasTraits):'
128 127 Raises :exc:`NoSuchKernel` if the given kernel name is not found.
129 128 """
130 129 if kernel_name in {'python', NATIVE_KERNEL_NAME}:
131 return KernelSpec(self._native_kernel_resource_dir, **self._native_kernel_dict)
130 return KernelSpec(resource_dir=self._native_kernel_resource_dir,
131 **self._native_kernel_dict)
132 132
133 133 d = self.find_kernel_specs()
134 134 try:
@@ -187,7 +187,9 b' class KernelSpecManager(HasTraits):'
187 187 os.makedirs(path, mode=0o755)
188 188 with open(pjoin(path, 'kernel.json'), 'w') as f:
189 189 json.dump(self._native_kernel_dict, f, indent=1)
190 # TODO: Copy icons into directory
190 copy_from = self._native_kernel_resource_dir
191 for file in os.listdir(copy_from):
192 shutil.copy(pjoin(copy_from, file), path)
191 193 return path
192 194
193 195 def find_kernel_specs():
General Comments 0
You need to be logged in to leave comments. Login now