Skip to content

Commit

Permalink
Merge pull request #1279 from meeseeksmachine/auto-backport-of-pr-127…
Browse files Browse the repository at this point in the history
…8-on-0.6.x

Backport PR #1278 on branch 0.6.x (Fix course list hanging when exchange has not been created )
  • Loading branch information
jhamrick committed Nov 3, 2019
2 parents 51e8d72 + 4186a08 commit 67229d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 8 additions & 2 deletions nbgrader/nbextensions/course_list/course_list.js
Expand Up @@ -123,17 +123,23 @@ define([

Course.prototype.make_row = function () {
var row = $('<div/>').addClass('col-md-12');
var course_id = this.course_id;

if(course_id === '') {
course_id = 'Default formgrader';
}

var container = $('<span/>').addClass('item_name col-sm-2').append(
$('<a/>')
.attr('href', this.url)
.attr('target', '_blank')
.text(this.course_id));
.text(course_id));
row.append(container);
row.append($('<span/>').addClass('item_course col-sm-2').text(this.formgrader_kind));
this.element.empty().append(row);
};

return {
'CourseList': CourseList,
'CourseList': CourseList
};
});
10 changes: 7 additions & 3 deletions nbgrader/server_extensions/course_list/handlers.py
Expand Up @@ -6,7 +6,7 @@
import traceback

from tornado import web
from tornado.httpclient import AsyncHTTPClient, HTTPClientError
from tornado.httpclient import AsyncHTTPClient, HTTPError
from tornado import gen
from textwrap import dedent
from six.moves import urllib
Expand Down Expand Up @@ -61,7 +61,7 @@ def check_for_local_formgrader(self, config):
http_client = AsyncHTTPClient()
try:
response = yield http_client.fetch(url, headers=header)
except HTTPClientError:
except HTTPError:
# local formgrader isn't running
self.log.warning("Local formgrader does not seem to be running")
raise gen.Return([])
Expand All @@ -74,9 +74,11 @@ def check_for_local_formgrader(self, config):
self.log.error(traceback.format_exc())
raise gen.Return([])

coursedir = CourseDirectory(config=config)

if status:
raise gen.Return([{
'course_id': config.CourseDirectory.course_id,
'course_id': coursedir.course_id,
'url': base_url + '/formgrader',
'kind': 'local'
}])
Expand All @@ -95,6 +97,7 @@ def check_for_noauth_jupyterhub_formgraders(self, config):
# We are running on JupyterHub, so maybe there's a formgrader
# service. Check if we have a course id and if so guess the path to the
# formgrader.

coursedir = CourseDirectory(config=config)
if not coursedir.course_id:
raise gen.Return([])
Expand Down Expand Up @@ -168,6 +171,7 @@ def get(self):
courses = []
local_courses = yield self.check_for_local_formgrader(config)
jhub_courses = yield self.check_for_jupyterhub_formgraders(config)

courses.extend(local_courses)
courses.extend(jhub_courses)

Expand Down

0 comments on commit 67229d2

Please sign in to comment.