Commit 5f723e8d by Sarina Canelake

s/pylint: disable=W0703/pylint: disable=broad-except/

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