From 4b1974cdbca73e5da781a44adde0435508f1b09a Mon Sep 17 00:00:00 2001 From: Gabe Mulley Date: Fri, 15 Nov 2013 08:50:33 -0500 Subject: [PATCH] fix spammy log messages from course_id tracking in CMS --- common/djangoapps/track/contexts.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/common/djangoapps/track/contexts.py b/common/djangoapps/track/contexts.py index 90a14736b4..0fb06fb1b1 100644 --- a/common/djangoapps/track/contexts.py +++ b/common/djangoapps/track/contexts.py @@ -43,15 +43,17 @@ def course_context_from_course_id(course_id): 'course_id': course_id, 'org_id': '' } - try: - location = CourseDescriptor.id_to_location(course_id) - context['org_id'] = location.org - except ValueError: - log.warning( - 'Unable to parse course_id "{course_id}"'.format( - course_id=course_id - ), - exc_info=True - ) + + if course_id: + try: + location = CourseDescriptor.id_to_location(course_id) + context['org_id'] = location.org + except ValueError: + log.warning( + 'Unable to parse course_id "{course_id}"'.format( + course_id=course_id + ), + exc_info=True + ) return context