Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cms/djangoapps/contentstore/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,11 @@ def get_dir_for_filename(directory, filename):
return

if not user_has_access(user):
logging.info(f'Course import {course_key_string}: User is not allowed to import')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is required.

return

if not file_is_supported():
logging.info(f'Course import {course_key_string}: File not supported')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is required.

return

is_library = isinstance(courselike_key, LibraryLocator)
Expand Down Expand Up @@ -737,14 +739,18 @@ def validate_course_olx(courselike_key, course_dir, status):
if not course_import_olx_validation_is_enabled():
return olx_is_valid
try:
if str(courselike_key) == "course-v1:ArbiX+CS101+2014_T3":
logging.info(log_prefix + "Validating. Calling olxcleaner.validate")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is log_prefix here?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default prefix they are using in every log of this function. This string is equal to f"Course import {courselike_key}"

__, errorstore, __ = olxcleaner.validate(
filename=course_dir,
steps=settings.COURSE_OLX_VALIDATION_STAGE,
ignore=settings.COURSE_OLX_VALIDATION_IGNORE_LIST,
allowed_xblocks=ALL_ALLOWED_XBLOCKS
)
except Exception: # pylint: disable=broad-except
LOGGER.exception(f'{log_prefix}: CourseOlx could not be validated')
if str(courselike_key) == "course-v1:ArbiX+CS101+2014_T3":
logging.info(log_prefix + "Course validated. No errors")
except Exception as e: # pylint: disable=broad-except

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this changed?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added "as e" after Exception to print it. Awais bhai told me LOGGER.Exception prints exception. Restored old code.

LOGGER.exception(f'{log_prefix}: CourseOlx could not be validated' + str(e))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOGGER.exception automatically prints the stack trace so I don't think `str(e) is needed here.

return olx_is_valid

has_errors = errorstore.return_error(ErrorLevel.ERROR.value)
Expand Down
8 changes: 8 additions & 0 deletions cms/djangoapps/contentstore/views/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ def import_status_handler(request, course_key_string, filename=None):
4 : Import successful

"""
if str(courselike_key) == "course-v1:ArbiX+CS101+2014_T3":
log.info(f"Import Status Handler {course_key_string}: Begin} ")

course_key = CourseKey.from_string(course_key_string)
if not has_course_author_access(request.user, course_key):
raise PermissionDenied()
Expand All @@ -259,6 +262,8 @@ def import_status_handler(request, course_key_string, filename=None):
for status_filter in STATUS_FILTERS:
task_status = status_filter().filter_queryset(request, task_status, import_status_handler)
task_status = task_status.order_by('-created').first()
if str(courselike_key) == "course-v1:ArbiX+CS101+2014_T3":
log.info("Selected task status for course " + str(task_status.__dict__))
if task_status is None:
# The task hasn't been initialized yet; did we store info in the session already?
try:
Expand All @@ -276,6 +281,9 @@ def import_status_handler(request, course_key_string, filename=None):
else:
status = min(task_status.completed_steps + 1, 3)

if str(courselike_key) == "course-v1:ArbiX+CS101+2014_T3":
log.info("Status for course " + str(status))

return JsonResponse({"ImportStatus": status, "Message": message})


Expand Down
2 changes: 2 additions & 0 deletions common/djangoapps/util/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ def monitor_import_failure(course_key, import_step, message=None, exception=None
"""
set_custom_attribute('course_import_failure', import_step)
set_custom_attributes_for_course_key(course_key)
logging.info(f"Course import failed at step {import_step} for course with key {course_key}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't these also be behind the course key condition?


if message:
set_custom_attribute('course_import_failure_message', message)
logging.info(f"Course import failed message {message}")

if exception is not None:
exception_module = getattr(exception, '__module__', '')
Expand Down