s/pylint: disable=W0703/pylint: disable=broad-except/
This commit is contained in:
@@ -152,7 +152,7 @@ def import_handler(request, course_key_string):
|
||||
}]
|
||||
})
|
||||
# Send errors to client with stage at which error occurred.
|
||||
except Exception as exception: # pylint: disable=W0703
|
||||
except Exception as exception: # pylint: disable=broad-except
|
||||
_save_request_status(request, key, -1)
|
||||
if course_dir.isdir():
|
||||
shutil.rmtree(course_dir)
|
||||
@@ -251,7 +251,7 @@ def import_handler(request, course_key_string):
|
||||
_save_request_status(request, key, 4)
|
||||
|
||||
# Send errors to client with stage at which error occurred.
|
||||
except Exception as exception: # pylint: disable=W0703
|
||||
except Exception as exception: # pylint: disable=broad-except
|
||||
log.exception(
|
||||
"error importing course"
|
||||
)
|
||||
|
||||
@@ -221,7 +221,7 @@ def xblock_view_handler(request, usage_key_string, view_name):
|
||||
# catch exceptions indiscriminately, since after this point they escape the
|
||||
# dungeon and surface as uneditable, unsaveable, and undeletable
|
||||
# component-goblins.
|
||||
except Exception as exc: # pylint: disable=w0703
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
log.debug("unable to render studio_view for %r", xblock, exc_info=True)
|
||||
fragment = Fragment(render_to_string('html_error.html', {'message': str(exc)}))
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ def get_preview_fragment(request, descriptor, context):
|
||||
|
||||
try:
|
||||
fragment = module.render(preview_view, context)
|
||||
except Exception as exc: # pylint: disable=W0703
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
log.warning("Unable to render %s for %r", preview_view, module, exc_info=True)
|
||||
fragment = Fragment(render_to_string('html_error.html', {'message': str(exc)}))
|
||||
return fragment
|
||||
|
||||
@@ -2229,7 +2229,7 @@ class ExternalResponse(LoncapaResponse):
|
||||
cmap = CorrectMap()
|
||||
try:
|
||||
submission = [student_answers[k] for k in idset]
|
||||
except Exception as err: # pylint: disable=W0703
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
log.error(
|
||||
'Error %s: cannot get student answer for %s; student_answers=%s',
|
||||
err,
|
||||
@@ -2244,7 +2244,7 @@ class ExternalResponse(LoncapaResponse):
|
||||
|
||||
try:
|
||||
rxml = self.do_external_request('get_score', extra_payload)
|
||||
except Exception as err: # pylint: disable=W0703
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
log.error('Error %s', err)
|
||||
if self.capa_system.DEBUG:
|
||||
cmap.set_dict(dict(zip(sorted(
|
||||
@@ -2276,7 +2276,7 @@ class ExternalResponse(LoncapaResponse):
|
||||
try:
|
||||
rxml = self.do_external_request('get_answers', {})
|
||||
exans = json.loads(rxml.find('expected').text)
|
||||
except Exception as err: # pylint: disable=W0703
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
log.error('Error %s', err)
|
||||
if self.capa_system.DEBUG:
|
||||
msg = '<span class="inline-error">%s</span>' % str(
|
||||
@@ -2486,7 +2486,7 @@ class FormulaResponse(LoncapaResponse):
|
||||
name = hxml.get('name')
|
||||
correct_answer = contextualize_text(
|
||||
hxml.get('answer'), self.context)
|
||||
# pylint: disable=W0703
|
||||
# pylint: disable=broad-except
|
||||
try:
|
||||
correctness = self.check_formula(
|
||||
correct_answer,
|
||||
|
||||
@@ -605,7 +605,7 @@ def _import_course_draft(
|
||||
|
||||
drafts.append(draft)
|
||||
|
||||
except Exception: # pylint: disable=W0703
|
||||
except Exception: # pylint: disable=broad-except
|
||||
logging.exception('Error while parsing course xml.')
|
||||
|
||||
# sort drafts by `index_in_children_list` attribute
|
||||
@@ -614,7 +614,7 @@ def _import_course_draft(
|
||||
for draft in get_draft_subtree_roots(drafts):
|
||||
try:
|
||||
_import_module(draft.module)
|
||||
except Exception: # pylint: disable=W0703
|
||||
except Exception: # pylint: disable=broad-except
|
||||
logging.exception('while importing draft descriptor %s', draft.module)
|
||||
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class StudentModuleHistoryCleaner(object):
|
||||
for smid in self.module_ids_to_check(batch_size):
|
||||
try:
|
||||
self.clean_one_student_module(smid)
|
||||
except Exception: # pylint: disable=W0703
|
||||
except Exception: # pylint: disable=broad-except
|
||||
trace = traceback.format_exc()
|
||||
self.say("Couldn't clean student_module_id {}:\n{}".format(smid, trace))
|
||||
if not self.dry_run:
|
||||
|
||||
@@ -261,7 +261,7 @@ def register_and_enroll_students(request, course_id): # pylint: disable=too-man
|
||||
try:
|
||||
upload_file = request.FILES.get('students_list')
|
||||
students = [row for row in csv.reader(upload_file.read().splitlines())]
|
||||
except Exception: # pylint: disable=W0703
|
||||
except Exception: # pylint: disable=broad-except
|
||||
general_errors.append({
|
||||
'username': '', 'email': '', 'response': _('Could not read uploaded file.')
|
||||
})
|
||||
@@ -488,7 +488,7 @@ def students_update_enrollment(request, course_id):
|
||||
'invalidIdentifier': True,
|
||||
})
|
||||
|
||||
except Exception as exc: # pylint: disable=W0703
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
# catch and log any exceptions
|
||||
# so that one error doesn't cause a 500.
|
||||
log.exception("Error while #{}ing student")
|
||||
|
||||
@@ -421,7 +421,7 @@ class Order(models.Model):
|
||||
}
|
||||
})
|
||||
|
||||
except Exception: # pylint: disable=W0703
|
||||
except Exception: # pylint: disable=broad-except
|
||||
# Capturing all exceptions thrown while tracking analytics events. We do not want
|
||||
# an operation to fail because of an analytics event, so we will capture these
|
||||
# errors in the logs.
|
||||
|
||||
@@ -552,7 +552,7 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
|
||||
attempt = attempts[0]
|
||||
if attempt.status != "approved":
|
||||
return False
|
||||
except Exception: # pylint: disable=W0703
|
||||
except Exception: # pylint: disable=broad-except
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@@ -60,7 +60,7 @@ class CoffeeScriptWatcher(PatternMatchingEventHandler):
|
||||
print('\tCHANGED:', event.src_path)
|
||||
try:
|
||||
compile_coffeescript(event.src_path)
|
||||
except Exception: # pylint: disable=W0703
|
||||
except Exception: # pylint: disable=broad-except
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class SassWatcher(PatternMatchingEventHandler):
|
||||
print('\tCHANGED:', event.src_path)
|
||||
try:
|
||||
compile_sass()
|
||||
except Exception: # pylint: disable=W0703
|
||||
except Exception: # pylint: disable=broad-except
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class XModuleSassWatcher(SassWatcher):
|
||||
print('\tCHANGED:', event.src_path)
|
||||
try:
|
||||
process_xmodule_assets()
|
||||
except Exception: # pylint: disable=W0703
|
||||
except Exception: # pylint: disable=broad-except
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user