##// 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
NO CONTENT: new file 100644, binary diff hidden
@@ -1,102 +1,103
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3
3
4 define([
4 define([
5 'base/js/namespace',
5 'base/js/namespace',
6 'jquery',
6 'jquery',
7 'base/js/utils',
7 'base/js/utils',
8 ], function(IPython, $, utils) {
8 ], function(IPython, $, utils) {
9 "use strict";
9 "use strict";
10
10
11 var KernelSelector = function(selector, notebook) {
11 var KernelSelector = function(selector, notebook) {
12 this.selector = selector;
12 this.selector = selector;
13 this.notebook = notebook;
13 this.notebook = notebook;
14 this.events = notebook.events;
14 this.events = notebook.events;
15 this.current_selection = null;
15 this.current_selection = null;
16 this.kernelspecs = {};
16 this.kernelspecs = {};
17 if (this.selector !== undefined) {
17 if (this.selector !== undefined) {
18 this.element = $(selector);
18 this.element = $(selector);
19 this.request_kernelspecs();
19 this.request_kernelspecs();
20 }
20 }
21 this.bind_events();
21 this.bind_events();
22 // Make the object globally available for user convenience & inspection
22 // Make the object globally available for user convenience & inspection
23 IPython.kernelselector = this;
23 IPython.kernelselector = this;
24 };
24 };
25
25
26 KernelSelector.prototype.request_kernelspecs = function() {
26 KernelSelector.prototype.request_kernelspecs = function() {
27 var url = utils.url_join_encode(this.notebook.base_url, 'api/kernelspecs');
27 var url = utils.url_join_encode(this.notebook.base_url, 'api/kernelspecs');
28 utils.promising_ajax(url).then($.proxy(this._got_kernelspecs, this));
28 utils.promising_ajax(url).then($.proxy(this._got_kernelspecs, this));
29 };
29 };
30
30
31 KernelSelector.prototype._got_kernelspecs = function(data) {
31 KernelSelector.prototype._got_kernelspecs = function(data) {
32 this.kernelspecs = data.kernelspecs;
32 this.kernelspecs = data.kernelspecs;
33 var menu = this.element.find("#kernel_selector");
33 var menu = this.element.find("#kernel_selector");
34 var change_kernel_submenu = $("#menu-change-kernel-submenu");
34 var change_kernel_submenu = $("#menu-change-kernel-submenu");
35 var keys = Object.keys(data.kernelspecs).sort(function (a, b) {
35 var keys = Object.keys(data.kernelspecs).sort(function (a, b) {
36 // sort by display_name
36 // sort by display_name
37 var da = data.kernelspecs[a].display_name;
37 var da = data.kernelspecs[a].display_name;
38 var db = data.kernelspecs[b].display_name;
38 var db = data.kernelspecs[b].display_name;
39 if (da === db) {
39 if (da === db) {
40 return 0;
40 return 0;
41 } else if (da > db) {
41 } else if (da > db) {
42 return 1;
42 return 1;
43 } else {
43 } else {
44 return -1;
44 return -1;
45 }
45 }
46 });
46 });
47 for (var i = 0; i < keys.length; i++) {
47 for (var i = 0; i < keys.length; i++) {
48 var ks = this.kernelspecs[keys[i]];
48 var ks = this.kernelspecs[keys[i]];
49 var ksentry = $("<li>").attr("id", "kernel-" +ks.name).append($('<a>')
49 var ksentry = $("<li>").attr("id", "kernel-" +ks.name).append($('<a>')
50 .attr('href', '#')
50 .attr('href', '#')
51 .click($.proxy(this.change_kernel, this, ks.name))
51 .click($.proxy(this.change_kernel, this, ks.name))
52 .text(ks.display_name));
52 .text(ks.display_name));
53 menu.append(ksentry);
53 menu.append(ksentry);
54
54
55 var ks_submenu_entry = $("<li>").attr("id", "kernel-submenu-"+ks.name).append($('<a>')
55 var ks_submenu_entry = $("<li>").attr("id", "kernel-submenu-"+ks.name).append($('<a>')
56 .attr('href', '#')
56 .attr('href', '#')
57 .click($.proxy(this.change_kernel, this, ks.name))
57 .click($.proxy(this.change_kernel, this, ks.name))
58 .text(ks.display_name));
58 .text(ks.display_name));
59 change_kernel_submenu.append(ks_submenu_entry);
59 change_kernel_submenu.append(ks_submenu_entry);
60 }
60 }
61 };
61 };
62
62
63 KernelSelector.prototype.change_kernel = function(kernel_name) {
63 KernelSelector.prototype.change_kernel = function(kernel_name) {
64 if (kernel_name === this.current_selection) {
64 if (kernel_name === this.current_selection) {
65 return;
65 return;
66 }
66 }
67 var ks = this.kernelspecs[kernel_name];
67 var ks = this.kernelspecs[kernel_name];
68 try {
68 try {
69 this.notebook.start_session(kernel_name);
69 this.notebook.start_session(kernel_name);
70 } catch (e) {
70 } catch (e) {
71 if (e.name === 'SessionAlreadyStarting') {
71 if (e.name === 'SessionAlreadyStarting') {
72 console.log("Cannot change kernel while waiting for pending session start.");
72 console.log("Cannot change kernel while waiting for pending session start.");
73 } else {
73 } else {
74 // unhandled error
74 // unhandled error
75 throw e;
75 throw e;
76 }
76 }
77 // only trigger spec_changed if change was successful
77 // only trigger spec_changed if change was successful
78 return;
78 return;
79 }
79 }
80 this.events.trigger('spec_changed.Kernel', ks);
80 this.events.trigger('spec_changed.Kernel', ks);
81 };
81 };
82
82
83 KernelSelector.prototype.bind_events = function() {
83 KernelSelector.prototype.bind_events = function() {
84 var that = this;
84 var that = this;
85 this.events.on('spec_changed.Kernel', function(event, data) {
85 this.events.on('spec_changed.Kernel', function(event, data) {
86 that.current_selection = data.name;
86 that.current_selection = data.name;
87 that.element.find("#current_kernel_spec").find('.kernel_name').text(data.display_name);
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 this.events.on('kernel_created.Session', function(event, data) {
91 this.events.on('kernel_created.Session', function(event, data) {
91 if (data.kernel.name !== that.current_selection) {
92 if (data.kernel.name !== that.current_selection) {
92 // If we created a 'python' session, we only know if it's Python
93 // If we created a 'python' session, we only know if it's Python
93 // 3 or 2 on the server's reply, so we fire the event again to
94 // 3 or 2 on the server's reply, so we fire the event again to
94 // set things up.
95 // set things up.
95 var ks = that.kernelspecs[data.kernel.name];
96 var ks = that.kernelspecs[data.kernel.name];
96 that.events.trigger('spec_changed.Kernel', ks);
97 that.events.trigger('spec_changed.Kernel', ks);
97 }
98 }
98 });
99 });
99 };
100 };
100
101
101 return {'KernelSelector': KernelSelector};
102 return {'KernelSelector': KernelSelector};
102 });
103 });
@@ -1,331 +1,332
1 {% extends "page.html" %}
1 {% extends "page.html" %}
2
2
3 {% block stylesheet %}
3 {% block stylesheet %}
4
4
5 {% if mathjax_url %}
5 {% if mathjax_url %}
6 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full&delayStartupUntil=configured" charset="utf-8"></script>
6 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full&delayStartupUntil=configured" charset="utf-8"></script>
7 {% endif %}
7 {% endif %}
8 <script type="text/javascript">
8 <script type="text/javascript">
9 // MathJax disabled, set as null to distingish from *missing* MathJax,
9 // MathJax disabled, set as null to distingish from *missing* MathJax,
10 // where it will be undefined, and should prompt a dialog later.
10 // where it will be undefined, and should prompt a dialog later.
11 window.mathjax_url = "{{mathjax_url}}";
11 window.mathjax_url = "{{mathjax_url}}";
12 </script>
12 </script>
13
13
14 <link rel="stylesheet" href="{{ static_url("components/bootstrap-tour/build/css/bootstrap-tour.min.css") }}" type="text/css" />
14 <link rel="stylesheet" href="{{ static_url("components/bootstrap-tour/build/css/bootstrap-tour.min.css") }}" type="text/css" />
15 <link rel="stylesheet" href="{{ static_url("components/codemirror/lib/codemirror.css") }}">
15 <link rel="stylesheet" href="{{ static_url("components/codemirror/lib/codemirror.css") }}">
16
16
17 {{super()}}
17 {{super()}}
18
18
19 <link rel="stylesheet" href="{{ static_url("notebook/css/override.css") }}" type="text/css" />
19 <link rel="stylesheet" href="{{ static_url("notebook/css/override.css") }}" type="text/css" />
20
20
21 {% endblock %}
21 {% endblock %}
22
22
23 {% block params %}
23 {% block params %}
24
24
25 data-project="{{project}}"
25 data-project="{{project}}"
26 data-base-url="{{base_url}}"
26 data-base-url="{{base_url}}"
27 data-ws-url="{{ws_url}}"
27 data-ws-url="{{ws_url}}"
28 data-notebook-name="{{notebook_name}}"
28 data-notebook-name="{{notebook_name}}"
29 data-notebook-path="{{notebook_path}}"
29 data-notebook-path="{{notebook_path}}"
30 class="notebook_app"
30 class="notebook_app"
31
31
32 {% endblock %}
32 {% endblock %}
33
33
34
34
35 {% block headercontainer %}
35 {% block headercontainer %}
36
36
37
37
38 <span id="save_widget" class="nav pull-left">
38 <span id="save_widget" class="nav pull-left">
39 <span id="notebook_name"></span>
39 <span id="notebook_name"></span>
40 <span id="checkpoint_status"></span>
40 <span id="checkpoint_status"></span>
41 <span id="autosave_status"></span>
41 <span id="autosave_status"></span>
42 </span>
42 </span>
43
43
44 <span id="kernel_selector_widget" class="pull-right dropdown">
44 <span id="kernel_selector_widget" class="pull-right dropdown">
45 <img id="current_kernel_logo" src="/kernelspecs/python/logo-32.png"/>
45 <button class="dropdown-toggle btn btn-sm navbar-btn" data-toggle="dropdown" type='button' id="current_kernel_spec">
46 <button class="dropdown-toggle btn btn-sm navbar-btn" data-toggle="dropdown" type='button' id="current_kernel_spec">
46 <span class='kernel_name'>Kernel</span>
47 <span class='kernel_name'>Kernel</span>
47 <span class="caret"></span>
48 <span class="caret"></span>
48 </button>
49 </button>
49 <ul id="kernel_selector" class="dropdown-menu">
50 <ul id="kernel_selector" class="dropdown-menu">
50 </ul>
51 </ul>
51 </span>
52 </span>
52
53
53 {% endblock headercontainer %}
54 {% endblock headercontainer %}
54
55
55 {% block header %}
56 {% block header %}
56 <div id="menubar-container" class="container">
57 <div id="menubar-container" class="container">
57 <div id="menubar">
58 <div id="menubar">
58 <div id="menus" class="navbar navbar-default" role="navigation">
59 <div id="menus" class="navbar navbar-default" role="navigation">
59 <div class="container-fluid">
60 <div class="container-fluid">
60 <button type="button" class="btn btn-default navbar-btn navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
61 <button type="button" class="btn btn-default navbar-btn navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
61 <i class="fa fa-bars"></i>
62 <i class="fa fa-bars"></i>
62 <span class="navbar-text">Menu</span>
63 <span class="navbar-text">Menu</span>
63 </button>
64 </button>
64 <p id="kernel_indicator" class="navbar-text">
65 <p id="kernel_indicator" class="navbar-text">
65 <i id="kernel_indicator_icon"></i>
66 <i id="kernel_indicator_icon"></i>
66 </p>
67 </p>
67 <p id="modal_indicator" class="navbar-text">
68 <p id="modal_indicator" class="navbar-text">
68 <i id="modal_indicator_icon"></i>
69 <i id="modal_indicator_icon"></i>
69 </p>
70 </p>
70 <span id="notification_area"></span>
71 <span id="notification_area"></span>
71 <div class="navbar-collapse collapse">
72 <div class="navbar-collapse collapse">
72 <ul class="nav navbar-nav">
73 <ul class="nav navbar-nav">
73 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">File</a>
74 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">File</a>
74 <ul id="file_menu" class="dropdown-menu">
75 <ul id="file_menu" class="dropdown-menu">
75 <li id="new_notebook"
76 <li id="new_notebook"
76 title="Make a new notebook (Opens a new window)">
77 title="Make a new notebook (Opens a new window)">
77 <a href="#">New</a></li>
78 <a href="#">New</a></li>
78 <li id="open_notebook"
79 <li id="open_notebook"
79 title="Opens a new window with the Dashboard view">
80 title="Opens a new window with the Dashboard view">
80 <a href="#">Open...</a></li>
81 <a href="#">Open...</a></li>
81 <!-- <hr/> -->
82 <!-- <hr/> -->
82 <li class="divider"></li>
83 <li class="divider"></li>
83 <li id="copy_notebook"
84 <li id="copy_notebook"
84 title="Open a copy of this notebook's contents and start a new kernel">
85 title="Open a copy of this notebook's contents and start a new kernel">
85 <a href="#">Make a Copy...</a></li>
86 <a href="#">Make a Copy...</a></li>
86 <li id="rename_notebook"><a href="#">Rename...</a></li>
87 <li id="rename_notebook"><a href="#">Rename...</a></li>
87 <li id="save_checkpoint"><a href="#">Save and Checkpoint</a></li>
88 <li id="save_checkpoint"><a href="#">Save and Checkpoint</a></li>
88 <!-- <hr/> -->
89 <!-- <hr/> -->
89 <li class="divider"></li>
90 <li class="divider"></li>
90 <li id="restore_checkpoint" class="dropdown-submenu"><a href="#">Revert to Checkpoint</a>
91 <li id="restore_checkpoint" class="dropdown-submenu"><a href="#">Revert to Checkpoint</a>
91 <ul class="dropdown-menu">
92 <ul class="dropdown-menu">
92 <li><a href="#"></a></li>
93 <li><a href="#"></a></li>
93 <li><a href="#"></a></li>
94 <li><a href="#"></a></li>
94 <li><a href="#"></a></li>
95 <li><a href="#"></a></li>
95 <li><a href="#"></a></li>
96 <li><a href="#"></a></li>
96 <li><a href="#"></a></li>
97 <li><a href="#"></a></li>
97 </ul>
98 </ul>
98 </li>
99 </li>
99 <li class="divider"></li>
100 <li class="divider"></li>
100 <li id="print_preview"><a href="#">Print Preview</a></li>
101 <li id="print_preview"><a href="#">Print Preview</a></li>
101 <li class="dropdown-submenu"><a href="#">Download as</a>
102 <li class="dropdown-submenu"><a href="#">Download as</a>
102 <ul class="dropdown-menu">
103 <ul class="dropdown-menu">
103 <li id="download_ipynb"><a href="#">IPython Notebook (.ipynb)</a></li>
104 <li id="download_ipynb"><a href="#">IPython Notebook (.ipynb)</a></li>
104 <li id="download_script"><a href="#">Script</a></li>
105 <li id="download_script"><a href="#">Script</a></li>
105 <li id="download_html"><a href="#">HTML (.html)</a></li>
106 <li id="download_html"><a href="#">HTML (.html)</a></li>
106 <li id="download_rst"><a href="#">reST (.rst)</a></li>
107 <li id="download_rst"><a href="#">reST (.rst)</a></li>
107 <li id="download_pdf"><a href="#">PDF (.pdf)</a></li>
108 <li id="download_pdf"><a href="#">PDF (.pdf)</a></li>
108 </ul>
109 </ul>
109 </li>
110 </li>
110 <li class="divider"></li>
111 <li class="divider"></li>
111 <li id="trust_notebook"
112 <li id="trust_notebook"
112 title="Trust the output of this notebook">
113 title="Trust the output of this notebook">
113 <a href="#" >Trust Notebook</a></li>
114 <a href="#" >Trust Notebook</a></li>
114 <li class="divider"></li>
115 <li class="divider"></li>
115 <li id="kill_and_exit"
116 <li id="kill_and_exit"
116 title="Shutdown this notebook's kernel, and close this window">
117 title="Shutdown this notebook's kernel, and close this window">
117 <a href="#" >Close and halt</a></li>
118 <a href="#" >Close and halt</a></li>
118 </ul>
119 </ul>
119 </li>
120 </li>
120 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit</a>
121 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit</a>
121 <ul id="edit_menu" class="dropdown-menu">
122 <ul id="edit_menu" class="dropdown-menu">
122 <li id="cut_cell"><a href="#">Cut Cell</a></li>
123 <li id="cut_cell"><a href="#">Cut Cell</a></li>
123 <li id="copy_cell"><a href="#">Copy Cell</a></li>
124 <li id="copy_cell"><a href="#">Copy Cell</a></li>
124 <li id="paste_cell_above" class="disabled"><a href="#">Paste Cell Above</a></li>
125 <li id="paste_cell_above" class="disabled"><a href="#">Paste Cell Above</a></li>
125 <li id="paste_cell_below" class="disabled"><a href="#">Paste Cell Below</a></li>
126 <li id="paste_cell_below" class="disabled"><a href="#">Paste Cell Below</a></li>
126 <li id="paste_cell_replace" class="disabled"><a href="#">Paste Cell &amp; Replace</a></li>
127 <li id="paste_cell_replace" class="disabled"><a href="#">Paste Cell &amp; Replace</a></li>
127 <li id="delete_cell"><a href="#">Delete Cell</a></li>
128 <li id="delete_cell"><a href="#">Delete Cell</a></li>
128 <li id="undelete_cell" class="disabled"><a href="#">Undo Delete Cell</a></li>
129 <li id="undelete_cell" class="disabled"><a href="#">Undo Delete Cell</a></li>
129 <li class="divider"></li>
130 <li class="divider"></li>
130 <li id="split_cell"><a href="#">Split Cell</a></li>
131 <li id="split_cell"><a href="#">Split Cell</a></li>
131 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
132 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
132 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
133 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
133 <li class="divider"></li>
134 <li class="divider"></li>
134 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
135 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
135 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
136 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
136 <li class="divider"></li>
137 <li class="divider"></li>
137 <li id="edit_nb_metadata"><a href="#">Edit Notebook Metadata</a></li>
138 <li id="edit_nb_metadata"><a href="#">Edit Notebook Metadata</a></li>
138 </ul>
139 </ul>
139 </li>
140 </li>
140 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a>
141 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a>
141 <ul id="view_menu" class="dropdown-menu">
142 <ul id="view_menu" class="dropdown-menu">
142 <li id="toggle_header"
143 <li id="toggle_header"
143 title="Show/Hide the IPython Notebook logo and notebook title (above menu bar)">
144 title="Show/Hide the IPython Notebook logo and notebook title (above menu bar)">
144 <a href="#">Toggle Header</a></li>
145 <a href="#">Toggle Header</a></li>
145 <li id="toggle_toolbar"
146 <li id="toggle_toolbar"
146 title="Show/Hide the action icons (below menu bar)">
147 title="Show/Hide the action icons (below menu bar)">
147 <a href="#">Toggle Toolbar</a></li>
148 <a href="#">Toggle Toolbar</a></li>
148 </ul>
149 </ul>
149 </li>
150 </li>
150 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Insert</a>
151 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Insert</a>
151 <ul id="insert_menu" class="dropdown-menu">
152 <ul id="insert_menu" class="dropdown-menu">
152 <li id="insert_cell_above"
153 <li id="insert_cell_above"
153 title="Insert an empty Code cell above the currently active cell">
154 title="Insert an empty Code cell above the currently active cell">
154 <a href="#">Insert Cell Above</a></li>
155 <a href="#">Insert Cell Above</a></li>
155 <li id="insert_cell_below"
156 <li id="insert_cell_below"
156 title="Insert an empty Code cell below the currently active cell">
157 title="Insert an empty Code cell below the currently active cell">
157 <a href="#">Insert Cell Below</a></li>
158 <a href="#">Insert Cell Below</a></li>
158 </ul>
159 </ul>
159 </li>
160 </li>
160 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Cell</a>
161 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Cell</a>
161 <ul id="cell_menu" class="dropdown-menu">
162 <ul id="cell_menu" class="dropdown-menu">
162 <li id="run_cell" title="Run this cell, and move cursor to the next one">
163 <li id="run_cell" title="Run this cell, and move cursor to the next one">
163 <a href="#">Run</a></li>
164 <a href="#">Run</a></li>
164 <li id="run_cell_select_below" title="Run this cell, select below">
165 <li id="run_cell_select_below" title="Run this cell, select below">
165 <a href="#">Run and Select Below</a></li>
166 <a href="#">Run and Select Below</a></li>
166 <li id="run_cell_insert_below" title="Run this cell, insert below">
167 <li id="run_cell_insert_below" title="Run this cell, insert below">
167 <a href="#">Run and Insert Below</a></li>
168 <a href="#">Run and Insert Below</a></li>
168 <li id="run_all_cells" title="Run all cells in the notebook">
169 <li id="run_all_cells" title="Run all cells in the notebook">
169 <a href="#">Run All</a></li>
170 <a href="#">Run All</a></li>
170 <li id="run_all_cells_above" title="Run all cells above (but not including) this cell">
171 <li id="run_all_cells_above" title="Run all cells above (but not including) this cell">
171 <a href="#">Run All Above</a></li>
172 <a href="#">Run All Above</a></li>
172 <li id="run_all_cells_below" title="Run this cell and all cells below it">
173 <li id="run_all_cells_below" title="Run this cell and all cells below it">
173 <a href="#">Run All Below</a></li>
174 <a href="#">Run All Below</a></li>
174 <li class="divider"></li>
175 <li class="divider"></li>
175 <li id="change_cell_type" class="dropdown-submenu"
176 <li id="change_cell_type" class="dropdown-submenu"
176 title="All cells in the notebook have a cell type. By default, new cells are created as 'Code' cells">
177 title="All cells in the notebook have a cell type. By default, new cells are created as 'Code' cells">
177 <a href="#">Cell Type</a>
178 <a href="#">Cell Type</a>
178 <ul class="dropdown-menu">
179 <ul class="dropdown-menu">
179 <li id="to_code"
180 <li id="to_code"
180 title="Contents will be sent to the kernel for execution, and output will display in the footer of cell">
181 title="Contents will be sent to the kernel for execution, and output will display in the footer of cell">
181 <a href="#">Code</a></li>
182 <a href="#">Code</a></li>
182 <li id="to_markdown"
183 <li id="to_markdown"
183 title="Contents will be rendered as HTML and serve as explanatory text">
184 title="Contents will be rendered as HTML and serve as explanatory text">
184 <a href="#">Markdown</a></li>
185 <a href="#">Markdown</a></li>
185 <li id="to_raw"
186 <li id="to_raw"
186 title="Contents will pass through nbconvert unmodified">
187 title="Contents will pass through nbconvert unmodified">
187 <a href="#">Raw NBConvert</a></li>
188 <a href="#">Raw NBConvert</a></li>
188 </ul>
189 </ul>
189 </li>
190 </li>
190 <li class="divider"></li>
191 <li class="divider"></li>
191 <li id="current_outputs" class="dropdown-submenu"><a href="#">Current Output</a>
192 <li id="current_outputs" class="dropdown-submenu"><a href="#">Current Output</a>
192 <ul class="dropdown-menu">
193 <ul class="dropdown-menu">
193 <li id="toggle_current_output"
194 <li id="toggle_current_output"
194 title="Hide/Show the output of the current cell">
195 title="Hide/Show the output of the current cell">
195 <a href="#">Toggle</a>
196 <a href="#">Toggle</a>
196 </li>
197 </li>
197 <li id="toggle_current_output_scroll"
198 <li id="toggle_current_output_scroll"
198 title="Scroll the output of the current cell">
199 title="Scroll the output of the current cell">
199 <a href="#">Toggle Scrolling</a>
200 <a href="#">Toggle Scrolling</a>
200 </li>
201 </li>
201 <li id="clear_current_output"
202 <li id="clear_current_output"
202 title="Clear the output of the current cell">
203 title="Clear the output of the current cell">
203 <a href="#">Clear</a>
204 <a href="#">Clear</a>
204 </li>
205 </li>
205 </ul>
206 </ul>
206 </li>
207 </li>
207 <li id="all_outputs" class="dropdown-submenu"><a href="#">All Output</a>
208 <li id="all_outputs" class="dropdown-submenu"><a href="#">All Output</a>
208 <ul class="dropdown-menu">
209 <ul class="dropdown-menu">
209 <li id="toggle_all_output"
210 <li id="toggle_all_output"
210 title="Hide/Show the output of all cells">
211 title="Hide/Show the output of all cells">
211 <a href="#">Toggle</a>
212 <a href="#">Toggle</a>
212 </li>
213 </li>
213 <li id="toggle_all_output_scroll"
214 <li id="toggle_all_output_scroll"
214 title="Scroll the output of all cells">
215 title="Scroll the output of all cells">
215 <a href="#">Toggle Scrolling</a>
216 <a href="#">Toggle Scrolling</a>
216 </li>
217 </li>
217 <li id="clear_all_output"
218 <li id="clear_all_output"
218 title="Clear the output of all cells">
219 title="Clear the output of all cells">
219 <a href="#">Clear</a>
220 <a href="#">Clear</a>
220 </li>
221 </li>
221 </ul>
222 </ul>
222 </li>
223 </li>
223 </ul>
224 </ul>
224 </li>
225 </li>
225 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Kernel</a>
226 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Kernel</a>
226 <ul id="kernel_menu" class="dropdown-menu">
227 <ul id="kernel_menu" class="dropdown-menu">
227 <li id="int_kernel"
228 <li id="int_kernel"
228 title="Send KeyboardInterrupt (CTRL-C) to the Kernel">
229 title="Send KeyboardInterrupt (CTRL-C) to the Kernel">
229 <a href="#">Interrupt</a>
230 <a href="#">Interrupt</a>
230 </li>
231 </li>
231 <li id="restart_kernel"
232 <li id="restart_kernel"
232 title="Restart the Kernel">
233 title="Restart the Kernel">
233 <a href="#">Restart</a>
234 <a href="#">Restart</a>
234 </li>
235 </li>
235 <li id="reconnect_kernel"
236 <li id="reconnect_kernel"
236 title="Reconnect to the Kernel">
237 title="Reconnect to the Kernel">
237 <a href="#">Reconnect</a>
238 <a href="#">Reconnect</a>
238 </li>
239 </li>
239 <li class="divider"></li>
240 <li class="divider"></li>
240 <li id="menu-change-kernel" class="dropdown-submenu">
241 <li id="menu-change-kernel" class="dropdown-submenu">
241 <a href="#">Change kernel</a>
242 <a href="#">Change kernel</a>
242 <ul class="dropdown-menu" id="menu-change-kernel-submenu"></ul>
243 <ul class="dropdown-menu" id="menu-change-kernel-submenu"></ul>
243 </li>
244 </li>
244 </ul>
245 </ul>
245 </li>
246 </li>
246 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Help</a>
247 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Help</a>
247 <ul id="help_menu" class="dropdown-menu">
248 <ul id="help_menu" class="dropdown-menu">
248 <li id="notebook_tour" title="A quick tour of the notebook user interface"><a href="#">User Interface Tour</a></li>
249 <li id="notebook_tour" title="A quick tour of the notebook user interface"><a href="#">User Interface Tour</a></li>
249 <li id="keyboard_shortcuts" title="Opens a tooltip with all keyboard shortcuts"><a href="#">Keyboard Shortcuts</a></li>
250 <li id="keyboard_shortcuts" title="Opens a tooltip with all keyboard shortcuts"><a href="#">Keyboard Shortcuts</a></li>
250 <li class="divider"></li>
251 <li class="divider"></li>
251 {% set
252 {% set
252 sections = (
253 sections = (
253 (
254 (
254 ("http://ipython.org/documentation.html","IPython Help",True),
255 ("http://ipython.org/documentation.html","IPython Help",True),
255 ("http://nbviewer.ipython.org/github/ipython/ipython/tree/2.x/examples/Index.ipynb", "Notebook Help", True),
256 ("http://nbviewer.ipython.org/github/ipython/ipython/tree/2.x/examples/Index.ipynb", "Notebook Help", True),
256 ),(
257 ),(
257 ("http://docs.python.org","Python",True),
258 ("http://docs.python.org","Python",True),
258 ("http://help.github.com/articles/github-flavored-markdown","Markdown",True),
259 ("http://help.github.com/articles/github-flavored-markdown","Markdown",True),
259 ("http://docs.scipy.org/doc/numpy/reference/","NumPy",True),
260 ("http://docs.scipy.org/doc/numpy/reference/","NumPy",True),
260 ("http://docs.scipy.org/doc/scipy/reference/","SciPy",True),
261 ("http://docs.scipy.org/doc/scipy/reference/","SciPy",True),
261 ("http://matplotlib.org/contents.html","Matplotlib",True),
262 ("http://matplotlib.org/contents.html","Matplotlib",True),
262 ("http://docs.sympy.org/latest/index.html","SymPy",True),
263 ("http://docs.sympy.org/latest/index.html","SymPy",True),
263 ("http://pandas.pydata.org/pandas-docs/stable/","pandas", True)
264 ("http://pandas.pydata.org/pandas-docs/stable/","pandas", True)
264 )
265 )
265 )
266 )
266 %}
267 %}
267
268
268 {% for helplinks in sections %}
269 {% for helplinks in sections %}
269 {% for link in helplinks %}
270 {% for link in helplinks %}
270 <li><a href="{{link[0]}}" {{'target="_blank" title="Opens in a new window"' if link[2]}}>
271 <li><a href="{{link[0]}}" {{'target="_blank" title="Opens in a new window"' if link[2]}}>
271 {{'<i class="fa fa-external-link menu-icon pull-right"></i>' if link[2]}}
272 {{'<i class="fa fa-external-link menu-icon pull-right"></i>' if link[2]}}
272 {{link[1]}}
273 {{link[1]}}
273 </a></li>
274 </a></li>
274 {% endfor %}
275 {% endfor %}
275 {% if not loop.last %}
276 {% if not loop.last %}
276 <li class="divider"></li>
277 <li class="divider"></li>
277 {% endif %}
278 {% endif %}
278 {% endfor %}
279 {% endfor %}
279 <li class="divider"></li>
280 <li class="divider"></li>
280 <li title="About IPython Notebook"><a id="notebook_about" href="#">About</a></li>
281 <li title="About IPython Notebook"><a id="notebook_about" href="#">About</a></li>
281 </ul>
282 </ul>
282 </li>
283 </li>
283 </ul>
284 </ul>
284 </div>
285 </div>
285 </div>
286 </div>
286 </div>
287 </div>
287 </div>
288 </div>
288
289
289 <div id="maintoolbar" class="navbar">
290 <div id="maintoolbar" class="navbar">
290 <div class="toolbar-inner navbar-inner navbar-nobg">
291 <div class="toolbar-inner navbar-inner navbar-nobg">
291 <div id="maintoolbar-container" class="container"></div>
292 <div id="maintoolbar-container" class="container"></div>
292 </div>
293 </div>
293 </div>
294 </div>
294 </div>
295 </div>
295
296
296 <div class="lower-header-bar"></div>
297 <div class="lower-header-bar"></div>
297 {% endblock header %}
298 {% endblock header %}
298
299
299 {% block site %}
300 {% block site %}
300
301
301
302
302 <div id="ipython-main-app">
303 <div id="ipython-main-app">
303 <div id="notebook_panel">
304 <div id="notebook_panel">
304 <div id="notebook"></div>
305 <div id="notebook"></div>
305 </div>
306 </div>
306 </div>
307 </div>
307
308
308 <div id="pager">
309 <div id="pager">
309 <div id="pager-contents">
310 <div id="pager-contents">
310 <div id="pager-container" class="container"></div>
311 <div id="pager-container" class="container"></div>
311 </div>
312 </div>
312 <div id='pager-button-area'></div>
313 <div id='pager-button-area'></div>
313 </div>
314 </div>
314
315
315 <div id='tooltip' class='ipython_tooltip' style='display:none'></div>
316 <div id='tooltip' class='ipython_tooltip' style='display:none'></div>
316
317
317
318
318 {% endblock %}
319 {% endblock %}
319
320
320
321
321 {% block script %}
322 {% block script %}
322 {{super()}}
323 {{super()}}
323 <script type="text/javascript">
324 <script type="text/javascript">
324 sys_info = {{sys_info}};
325 sys_info = {{sys_info}};
325 </script>
326 </script>
326
327
327 <script src="{{ static_url("components/text-encoding/lib/encoding.js") }}" charset="utf-8"></script>
328 <script src="{{ static_url("components/text-encoding/lib/encoding.js") }}" charset="utf-8"></script>
328
329
329 <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>
330 <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>
330
331
331 {% endblock %}
332 {% endblock %}
@@ -1,213 +1,215
1 import io
1 import io
2 import json
2 import json
3 import os
3 import os
4 import shutil
4 import shutil
5 import sys
5 import sys
6
6
7 pjoin = os.path.join
7 pjoin = os.path.join
8
8
9 from IPython.utils.path import get_ipython_dir
9 from IPython.utils.path import get_ipython_dir
10 from IPython.utils.py3compat import PY3
10 from IPython.utils.py3compat import PY3
11 from IPython.utils.traitlets import HasTraits, List, Unicode, Dict, Any
11 from IPython.utils.traitlets import HasTraits, List, Unicode, Dict, Any
12 from .launcher import make_ipkernel_cmd
12 from .launcher import make_ipkernel_cmd
13
13
14 if os.name == 'nt':
14 if os.name == 'nt':
15 programdata = os.environ.get('PROGRAMDATA', None)
15 programdata = os.environ.get('PROGRAMDATA', None)
16 if programdata:
16 if programdata:
17 SYSTEM_KERNEL_DIRS = [pjoin(programdata, 'ipython', 'kernels')]
17 SYSTEM_KERNEL_DIRS = [pjoin(programdata, 'ipython', 'kernels')]
18 else: # PROGRAMDATA is not defined by default on XP.
18 else: # PROGRAMDATA is not defined by default on XP.
19 SYSTEM_KERNEL_DIRS = []
19 SYSTEM_KERNEL_DIRS = []
20 else:
20 else:
21 SYSTEM_KERNEL_DIRS = ["/usr/share/ipython/kernels",
21 SYSTEM_KERNEL_DIRS = ["/usr/share/ipython/kernels",
22 "/usr/local/share/ipython/kernels",
22 "/usr/local/share/ipython/kernels",
23 ]
23 ]
24
24
25 NATIVE_KERNEL_NAME = 'python3' if PY3 else 'python2'
25 NATIVE_KERNEL_NAME = 'python3' if PY3 else 'python2'
26
26
27 def _pythonfirst(s):
27 def _pythonfirst(s):
28 "Sort key function that will put strings starting with 'python' first."
28 "Sort key function that will put strings starting with 'python' first."
29 if s == NATIVE_KERNEL_NAME:
29 if s == NATIVE_KERNEL_NAME:
30 return ' ' + s # Two spaces to sort this first of all
30 return ' ' + s # Two spaces to sort this first of all
31 elif s.startswith('python'):
31 elif s.startswith('python'):
32 # Space is not valid in kernel names, so this should sort first
32 # Space is not valid in kernel names, so this should sort first
33 return ' ' + s
33 return ' ' + s
34 return s
34 return s
35
35
36 class KernelSpec(HasTraits):
36 class KernelSpec(HasTraits):
37 argv = List()
37 argv = List()
38 display_name = Unicode()
38 display_name = Unicode()
39 env = Dict()
39 env = Dict()
40 resource_dir = Unicode()
40 resource_dir = Unicode()
41
41
42 @classmethod
42 @classmethod
43 def from_resource_dir(cls, resource_dir):
43 def from_resource_dir(cls, resource_dir):
44 """Create a KernelSpec object by reading kernel.json
44 """Create a KernelSpec object by reading kernel.json
45
45
46 Pass the path to the *directory* containing kernel.json.
46 Pass the path to the *directory* containing kernel.json.
47 """
47 """
48 kernel_file = pjoin(resource_dir, 'kernel.json')
48 kernel_file = pjoin(resource_dir, 'kernel.json')
49 with io.open(kernel_file, 'r', encoding='utf-8') as f:
49 with io.open(kernel_file, 'r', encoding='utf-8') as f:
50 kernel_dict = json.load(f)
50 kernel_dict = json.load(f)
51 return cls(resource_dir=resource_dir, **kernel_dict)
51 return cls(resource_dir=resource_dir, **kernel_dict)
52
52
53 def to_dict(self):
53 def to_dict(self):
54 d = dict(argv=self.argv,
54 d = dict(argv=self.argv,
55 env=self.env,
55 env=self.env,
56 display_name=self.display_name,
56 display_name=self.display_name,
57 )
57 )
58
58
59 return d
59 return d
60
60
61 def to_json(self):
61 def to_json(self):
62 return json.dumps(self.to_dict())
62 return json.dumps(self.to_dict())
63
63
64 def _is_kernel_dir(path):
64 def _is_kernel_dir(path):
65 """Is ``path`` a kernel directory?"""
65 """Is ``path`` a kernel directory?"""
66 return os.path.isdir(path) and os.path.isfile(pjoin(path, 'kernel.json'))
66 return os.path.isdir(path) and os.path.isfile(pjoin(path, 'kernel.json'))
67
67
68 def _list_kernels_in(dir):
68 def _list_kernels_in(dir):
69 """Return a mapping of kernel names to resource directories from dir.
69 """Return a mapping of kernel names to resource directories from dir.
70
70
71 If dir is None or does not exist, returns an empty dict.
71 If dir is None or does not exist, returns an empty dict.
72 """
72 """
73 if dir is None or not os.path.isdir(dir):
73 if dir is None or not os.path.isdir(dir):
74 return {}
74 return {}
75 return {f.lower(): pjoin(dir, f) for f in os.listdir(dir)
75 return {f.lower(): pjoin(dir, f) for f in os.listdir(dir)
76 if _is_kernel_dir(pjoin(dir, f))}
76 if _is_kernel_dir(pjoin(dir, f))}
77
77
78 class NoSuchKernel(KeyError):
78 class NoSuchKernel(KeyError):
79 def __init__(self, name):
79 def __init__(self, name):
80 self.name = name
80 self.name = name
81
81
82 class KernelSpecManager(HasTraits):
82 class KernelSpecManager(HasTraits):
83 ipython_dir = Unicode()
83 ipython_dir = Unicode()
84 def _ipython_dir_default(self):
84 def _ipython_dir_default(self):
85 return get_ipython_dir()
85 return get_ipython_dir()
86
86
87 user_kernel_dir = Unicode()
87 user_kernel_dir = Unicode()
88 def _user_kernel_dir_default(self):
88 def _user_kernel_dir_default(self):
89 return pjoin(self.ipython_dir, 'kernels')
89 return pjoin(self.ipython_dir, 'kernels')
90
90
91 kernel_dirs = List(
91 kernel_dirs = List(
92 help="List of kernel directories to search. Later ones take priority over earlier."
92 help="List of kernel directories to search. Later ones take priority over earlier."
93 )
93 )
94 def _kernel_dirs_default(self):
94 def _kernel_dirs_default(self):
95 return SYSTEM_KERNEL_DIRS + [
95 return SYSTEM_KERNEL_DIRS + [
96 self.user_kernel_dir,
96 self.user_kernel_dir,
97 ]
97 ]
98
98
99 @property
99 @property
100 def _native_kernel_dict(self):
100 def _native_kernel_dict(self):
101 """Makes a kernel directory for the native kernel.
101 """Makes a kernel directory for the native kernel.
102
102
103 The native kernel is the kernel using the same Python runtime as this
103 The native kernel is the kernel using the same Python runtime as this
104 process. This will put its informatino in the user kernels directory.
104 process. This will put its informatino in the user kernels directory.
105 """
105 """
106 return {'argv': make_ipkernel_cmd(),
106 return {'argv': make_ipkernel_cmd(),
107 'display_name': 'IPython (Python %d)' % (3 if PY3 else 2),
107 'display_name': 'IPython (Python %d)' % (3 if PY3 else 2),
108 }
108 }
109
109
110 @property
110 @property
111 def _native_kernel_resource_dir(self):
111 def _native_kernel_resource_dir(self):
112 # TODO: This may be different when we actually have any resources
112 return pjoin(os.path.dirname(__file__), 'resources')
113 return os.path.dirname(__file__)
114
113
115 def find_kernel_specs(self):
114 def find_kernel_specs(self):
116 """Returns a dict mapping kernel names to resource directories."""
115 """Returns a dict mapping kernel names to resource directories."""
117 d = {}
116 d = {}
118 for kernel_dir in self.kernel_dirs:
117 for kernel_dir in self.kernel_dirs:
119 d.update(_list_kernels_in(kernel_dir))
118 d.update(_list_kernels_in(kernel_dir))
120
119
121 d[NATIVE_KERNEL_NAME] = self._native_kernel_resource_dir
120 d[NATIVE_KERNEL_NAME] = self._native_kernel_resource_dir
122 return d
121 return d
123 # TODO: Caching?
122 # TODO: Caching?
124
123
125 def get_kernel_spec(self, kernel_name):
124 def get_kernel_spec(self, kernel_name):
126 """Returns a :class:`KernelSpec` instance for the given kernel_name.
125 """Returns a :class:`KernelSpec` instance for the given kernel_name.
127
126
128 Raises :exc:`NoSuchKernel` if the given kernel name is not found.
127 Raises :exc:`NoSuchKernel` if the given kernel name is not found.
129 """
128 """
130 if kernel_name in {'python', NATIVE_KERNEL_NAME}:
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 d = self.find_kernel_specs()
133 d = self.find_kernel_specs()
134 try:
134 try:
135 resource_dir = d[kernel_name.lower()]
135 resource_dir = d[kernel_name.lower()]
136 except KeyError:
136 except KeyError:
137 raise NoSuchKernel(kernel_name)
137 raise NoSuchKernel(kernel_name)
138 return KernelSpec.from_resource_dir(resource_dir)
138 return KernelSpec.from_resource_dir(resource_dir)
139
139
140 def _get_destination_dir(self, kernel_name, system=False):
140 def _get_destination_dir(self, kernel_name, system=False):
141 if system:
141 if system:
142 if SYSTEM_KERNEL_DIRS:
142 if SYSTEM_KERNEL_DIRS:
143 return os.path.join(SYSTEM_KERNEL_DIRS[-1], kernel_name)
143 return os.path.join(SYSTEM_KERNEL_DIRS[-1], kernel_name)
144 else:
144 else:
145 raise EnvironmentError("No system kernel directory is available")
145 raise EnvironmentError("No system kernel directory is available")
146 else:
146 else:
147 return os.path.join(self.user_kernel_dir, kernel_name)
147 return os.path.join(self.user_kernel_dir, kernel_name)
148
148
149 def install_kernel_spec(self, source_dir, kernel_name=None, system=False,
149 def install_kernel_spec(self, source_dir, kernel_name=None, system=False,
150 replace=False):
150 replace=False):
151 """Install a kernel spec by copying its directory.
151 """Install a kernel spec by copying its directory.
152
152
153 If ``kernel_name`` is not given, the basename of ``source_dir`` will
153 If ``kernel_name`` is not given, the basename of ``source_dir`` will
154 be used.
154 be used.
155
155
156 If ``system`` is True, it will attempt to install into the systemwide
156 If ``system`` is True, it will attempt to install into the systemwide
157 kernel registry. If the process does not have appropriate permissions,
157 kernel registry. If the process does not have appropriate permissions,
158 an :exc:`OSError` will be raised.
158 an :exc:`OSError` will be raised.
159
159
160 If ``replace`` is True, this will replace an existing kernel of the same
160 If ``replace`` is True, this will replace an existing kernel of the same
161 name. Otherwise, if the destination already exists, an :exc:`OSError`
161 name. Otherwise, if the destination already exists, an :exc:`OSError`
162 will be raised.
162 will be raised.
163 """
163 """
164 if not kernel_name:
164 if not kernel_name:
165 kernel_name = os.path.basename(source_dir)
165 kernel_name = os.path.basename(source_dir)
166 kernel_name = kernel_name.lower()
166 kernel_name = kernel_name.lower()
167
167
168 destination = self._get_destination_dir(kernel_name, system=system)
168 destination = self._get_destination_dir(kernel_name, system=system)
169
169
170 if replace and os.path.isdir(destination):
170 if replace and os.path.isdir(destination):
171 shutil.rmtree(destination)
171 shutil.rmtree(destination)
172
172
173 shutil.copytree(source_dir, destination)
173 shutil.copytree(source_dir, destination)
174
174
175 def install_native_kernel_spec(self, system=False):
175 def install_native_kernel_spec(self, system=False):
176 """Install the native kernel spec to the filesystem
176 """Install the native kernel spec to the filesystem
177
177
178 This allows a Python 3 frontend to use a Python 2 kernel, or vice versa.
178 This allows a Python 3 frontend to use a Python 2 kernel, or vice versa.
179 The kernelspec will be written pointing to the Python executable on
179 The kernelspec will be written pointing to the Python executable on
180 which this is run.
180 which this is run.
181
181
182 If ``system`` is True, it will attempt to install into the systemwide
182 If ``system`` is True, it will attempt to install into the systemwide
183 kernel registry. If the process does not have appropriate permissions,
183 kernel registry. If the process does not have appropriate permissions,
184 an :exc:`OSError` will be raised.
184 an :exc:`OSError` will be raised.
185 """
185 """
186 path = self._get_destination_dir(NATIVE_KERNEL_NAME, system=system)
186 path = self._get_destination_dir(NATIVE_KERNEL_NAME, system=system)
187 os.makedirs(path, mode=0o755)
187 os.makedirs(path, mode=0o755)
188 with open(pjoin(path, 'kernel.json'), 'w') as f:
188 with open(pjoin(path, 'kernel.json'), 'w') as f:
189 json.dump(self._native_kernel_dict, f, indent=1)
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 return path
193 return path
192
194
193 def find_kernel_specs():
195 def find_kernel_specs():
194 """Returns a dict mapping kernel names to resource directories."""
196 """Returns a dict mapping kernel names to resource directories."""
195 return KernelSpecManager().find_kernel_specs()
197 return KernelSpecManager().find_kernel_specs()
196
198
197 def get_kernel_spec(kernel_name):
199 def get_kernel_spec(kernel_name):
198 """Returns a :class:`KernelSpec` instance for the given kernel_name.
200 """Returns a :class:`KernelSpec` instance for the given kernel_name.
199
201
200 Raises KeyError if the given kernel name is not found.
202 Raises KeyError if the given kernel name is not found.
201 """
203 """
202 return KernelSpecManager().get_kernel_spec(kernel_name)
204 return KernelSpecManager().get_kernel_spec(kernel_name)
203
205
204 def install_kernel_spec(source_dir, kernel_name=None, system=False, replace=False):
206 def install_kernel_spec(source_dir, kernel_name=None, system=False, replace=False):
205 return KernelSpecManager().install_kernel_spec(source_dir, kernel_name,
207 return KernelSpecManager().install_kernel_spec(source_dir, kernel_name,
206 system, replace)
208 system, replace)
207
209
208 install_kernel_spec.__doc__ = KernelSpecManager.install_kernel_spec.__doc__
210 install_kernel_spec.__doc__ = KernelSpecManager.install_kernel_spec.__doc__
209
211
210 def install_native_kernel_spec(self, system=False):
212 def install_native_kernel_spec(self, system=False):
211 return KernelSpecManager().install_native_kernel_spec(system=system)
213 return KernelSpecManager().install_native_kernel_spec(system=system)
212
214
213 install_native_kernel_spec.__doc__ = KernelSpecManager.install_native_kernel_spec.__doc__
215 install_native_kernel_spec.__doc__ = KernelSpecManager.install_native_kernel_spec.__doc__
General Comments 0
You need to be logged in to leave comments. Login now