diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 867eef3bb8..ea9536a387 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -52,9 +52,9 @@ def get_course(course_id, depth=0): course_loc = CourseDescriptor.id_to_location(course_id) return modulestore().get_instance(course_id, course_loc, depth=depth) except (KeyError, ItemNotFoundError): - raise ValueError("Course not found: {}".format(course_id)) + raise ValueError(u"Course not found: {0}".format(course_id)) except InvalidLocationError: - raise ValueError("Invalid location: {}".format(course_id)) + raise ValueError(u"Invalid location: {0}".format(course_id)) def get_course_by_id(course_id, depth=0): @@ -127,7 +127,7 @@ def find_file(filesystem, dirs, filename): filepath = path(directory) / filename if filesystem.exists(filepath): return filepath - raise ResourceNotFoundError("Could not find {0}".format(filename)) + raise ResourceNotFoundError(u"Could not find {0}".format(filename)) def get_course_about_section(course, section_key): @@ -191,15 +191,16 @@ def get_course_about_section(course, section_key): html = about_module.render('student_view').content except Exception: # pylint: disable=broad-except html = render_to_string('courseware/error-message.html', None) - log.exception("Error rendering course={course}, section_key={section_key}".format( - course=course, - section_key=section_key - )) + log.exception( + u"Error rendering course={course}, section_key={section_key}".format( + course=course, section_key=section_key + )) return html except ItemNotFoundError: - log.warning("Missing about section {key} in course {url}".format( - key=section_key, url=course.location.url())) + log.warning( + u"Missing about section {key} in course {url}".format(key=section_key, url=course.location.url()) + ) return None elif section_key == "title": return course.display_name_with_default @@ -243,10 +244,10 @@ def get_course_info_section(request, course, section_key): html = info_module.render('student_view').content except Exception: # pylint: disable=broad-except html = render_to_string('courseware/error-message.html', None) - log.exception("Error rendering course={course}, section_key={section_key}".format( - course=course, - section_key=section_key - )) + log.exception( + u"Error rendering course={course}, section_key={section_key}".format( + course=course, section_key=section_key + )) return html @@ -282,8 +283,9 @@ def get_course_syllabus_section(course, section_key): static_asset_path=course.static_asset_path, ) except ResourceNotFoundError: - log.exception("Missing syllabus section {key} in course {url}".format( - key=section_key, url=course.location.url())) + log.exception( + u"Missing syllabus section {key} in course {url}".format(key=section_key, url=course.location.url()) + ) return "! Syllabus missing !" raise KeyError("Invalid about key " + str(section_key)) diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index aefa9faffd..695e6584dc 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -363,9 +363,8 @@ def index(request, course_id, chapter=None, section=None, raise else: log.exception( - "Error in index view: user={user}, course={course}," - " chapter={chapter} section={section}" - "position={position}".format( + u"Error in index view: user={user}, course={course}, chapter={chapter}" + u" section={section} position={position}".format( user=user, course=course, chapter=chapter, @@ -401,11 +400,15 @@ def jump_to_id(request, course_id, module_id): ) if len(items) == 0: - raise Http404("Could not find id = {0} in course_id = {1}. Referer = {2}". - format(module_id, course_id, request.META.get("HTTP_REFERER", ""))) + raise Http404( + u"Could not find id: {0} in course_id: {1}. Referer: {2}".format( + module_id, course_id, request.META.get("HTTP_REFERER", "") + )) if len(items) > 1: - log.warning("Multiple items found with id = {0} in course_id = {1}. Referer = {2}. Using first found {3}...". - format(module_id, course_id, request.META.get("HTTP_REFERER", ""), items[0].location.url())) + log.warning( + u"Multiple items found with id: {0} in course_id: {1}. Referer: {2}. Using first: {3}".format( + module_id, course_id, request.META.get("HTTP_REFERER", ""), items[0].location.url() + )) return jump_to(request, course_id, items[0].location.url()) @@ -791,9 +794,8 @@ def get_static_tab_contents(request, course, tab): html = tab_module.render('student_view').content except Exception: # pylint: disable=broad-except html = render_to_string('courseware/error-message.html', None) - log.exception("Error rendering course={course}, tab={tab_url}".format( - course=course, - tab_url=tab['url_slug'] - )) + log.exception( + u"Error rendering course={course}, tab={tab_url}".format(course=course,tab_url=tab['url_slug']) + ) return html diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py index 85b16e8fea..659b3ee25e 100644 --- a/lms/djangoapps/instructor/views/legacy.py +++ b/lms/djangoapps/instructor/views/legacy.py @@ -1519,7 +1519,7 @@ def get_and_clean_student_list(students): """ students = split_by_comma_and_whitespace(students) - students = [str(s.strip()) for s in students] + students = [unicode(s.strip()) for s in students] students = [s for s in students if s != ''] students_lc = [x.lower() for x in students]