##// END OF EJS Templates
Better user experience when kernel isn't found
Jessica B. Hamrick -
Show More
@@ -56,7 +56,11 b' class SessionRootHandler(IPythonHandler):'
56 try:
56 try:
57 model = sm.create_session(name=name, path=path, kernel_name=kernel_name)
57 model = sm.create_session(name=name, path=path, kernel_name=kernel_name)
58 except NoSuchKernel:
58 except NoSuchKernel:
59 raise web.HTTPError(400, "No such kernel: %s" % kernel_name)
59 msg = ("The '%s' kernel is not available. Please pick another "
60 "suitable kernel instead, or install that kernel." % kernel_name)
61 status_msg = 'Kernel not found'
62 msg = dict(full=msg, short=status_msg)
63 raise web.HTTPError(400, json.dumps(msg))
60
64
61 location = url_path_join(self.base_url, 'api', 'sessions', model['id'])
65 location = url_path_join(self.base_url, 'api', 'sessions', model['id'])
62 self.set_header('Location', url_escape(location))
66 self.set_header('Location', url_escape(location))
@@ -185,32 +185,22 b' define(['
185 });
185 });
186
186
187 this.events.on('start_failed.Session',function (session, xhr, status, error) {
187 this.events.on('start_failed.Session',function (session, xhr, status, error) {
188 var msg = $('<div/>');
188 var msg = JSON.parse(status.responseJSON.message);
189 msg.append($('<div/>')
190 .text('The kernel could not be started. This might ' +
191 'happen if the notebook was previously run with a kernel ' +
192 'that you do not have installed. Please choose a different kernel, ' +
193 'or install the needed kernel and then refresh this page.')
194 .css('margin-bottom', '1em'));
195
196 msg.append($('<div/>')
197 .text('The exact error was:')
198 .css('margin-bottom', '1em'));
199
200 msg.append($('<div/>')
201 .attr('class', 'alert alert-danger')
202 .attr('role', 'alert')
203 .text(JSON.parse(status.responseText).message));
204
189
190 that.save_widget.update_document_title();
191 $kernel_ind_icon.attr('class','kernel_dead_icon').attr('title','Kernel Dead');
192 knw.danger(msg.short, undefined, function () {
205 dialog.modal({
193 dialog.modal({
206 title: "Failed to start the kernel",
194 title: "Failed to start the kernel",
207 body : msg,
195 body : msg.full,
208 keyboard_manager: that.keyboard_manager,
196 keyboard_manager: that.keyboard_manager,
209 notebook: that.notebook,
197 notebook: that.notebook,
210 buttons : {
198 buttons : {
211 "Ok": { class: 'btn-primary' }
199 "Ok": { class: 'btn-primary' }
212 }
200 }
213 });
201 });
202 return false;
203 });
214 });
204 });
215
205
216 this.events.on('websocket_closed.Kernel', function (event, data) {
206 this.events.on('websocket_closed.Kernel', function (event, data) {
@@ -112,7 +112,6 b' define(['
112
112
113 Session.prototype._handle_start_failure = function (xhr, status, error) {
113 Session.prototype._handle_start_failure = function (xhr, status, error) {
114 this.events.trigger('start_failed.Session', [this, xhr, status, error]);
114 this.events.trigger('start_failed.Session', [this, xhr, status, error]);
115 this.events.trigger('status_dead.Kernel');
116 };
115 };
117
116
118 /**
117 /**
General Comments 0
You need to be logged in to leave comments. Login now