misc: pylint fix bare-except (#52222)
This commit is contained in:
parent
157f97a27a
commit
41bf7dfac9
|
@ -242,7 +242,7 @@ class UserFieldsFormDef(FormDef):
|
|||
if xml_import:
|
||||
try:
|
||||
tree = ET.fromstring(xml_import)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
obj = FormDef.import_from_xml_tree(tree, include_id=True)
|
||||
|
|
|
@ -2594,7 +2594,7 @@ class FormPage(Directory):
|
|||
x += (t - mean) ** 2.0
|
||||
try:
|
||||
variance = x // (len_times + 1)
|
||||
except:
|
||||
except Exception:
|
||||
variance = 0
|
||||
# not displayed since in square seconds which is not easy to grasp
|
||||
|
||||
|
@ -3267,7 +3267,7 @@ class FormBackOfficeStatusPage(FormStatusPage):
|
|||
else:
|
||||
try:
|
||||
v = force_text(v).encode(charset)
|
||||
except:
|
||||
except Exception:
|
||||
v = repr(v)
|
||||
return v
|
||||
|
||||
|
|
|
@ -398,7 +398,7 @@ class Field(object):
|
|||
if include_id:
|
||||
try:
|
||||
self.id = xml_node_text(elem.find('id'))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def condition_init_with_xml(self, node, charset, include_id=False, snapshot=False):
|
||||
|
@ -511,7 +511,7 @@ class Field(object):
|
|||
# will get the native python object)
|
||||
ret = str(ret)
|
||||
return (ret, explicit_lock)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
elif t == 'geolocation':
|
||||
|
@ -1142,7 +1142,7 @@ class TextField(WidgetField):
|
|||
+ htmltext('\n').join([(x or htmltext('</p><p>')) for x in value.splitlines()])
|
||||
+ htmltext('</p>')
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
return ''
|
||||
|
||||
def get_opendocument_node_value(self, value, formdata=None, **kwargs):
|
||||
|
|
|
@ -1069,7 +1069,7 @@ class FormDef(StorableObject):
|
|||
def import_from_xml(cls, fd, charset=None, include_id=False, fix_on_error=False, check_datasources=True):
|
||||
try:
|
||||
tree = ET.parse(fd)
|
||||
except:
|
||||
except Exception:
|
||||
raise ValueError()
|
||||
formdef = cls.import_from_xml_tree(
|
||||
tree,
|
||||
|
|
|
@ -54,7 +54,7 @@ def _find_vc_version():
|
|||
version = process.communicate()[0].splitlines()[-1].split()[2]
|
||||
if process.returncode == 0:
|
||||
return "%s %s (Debian)" % (package, version.decode())
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
@ -64,7 +64,7 @@ def _find_vc_version():
|
|||
setup_content = fd.read()
|
||||
version_line = [x for x in setup_content.splitlines() if 'version' in x][0]
|
||||
version = re.split('"|\'', version_line.split()[2])[1]
|
||||
except:
|
||||
except Exception:
|
||||
version = None
|
||||
|
||||
if os.path.exists(os.path.join(srcdir, '.git')):
|
||||
|
|
|
@ -39,7 +39,7 @@ class CronJob(object):
|
|||
def cron_worker(publisher, now, job_name=None):
|
||||
try:
|
||||
publisher.set_config()
|
||||
except:
|
||||
except Exception:
|
||||
return
|
||||
|
||||
# reindex user and formdata if needed (should only be run once)
|
||||
|
@ -74,5 +74,5 @@ def cron_worker(publisher, now, job_name=None):
|
|||
publisher.substitutions.feed(extra_source(publisher, None))
|
||||
try:
|
||||
job.function(publisher)
|
||||
except:
|
||||
except Exception:
|
||||
publisher.notify_of_exception(sys.exc_info(), context='[CRON]')
|
||||
|
|
|
@ -229,7 +229,7 @@ def email(
|
|||
)[0]
|
||||
# change paragraphs so manual newlines are considered.
|
||||
htmlmail = force_str(htmlmail).replace('<p>', '<p style="white-space: pre-line;">')
|
||||
except:
|
||||
except Exception:
|
||||
htmlmail = None
|
||||
|
||||
try:
|
||||
|
|
|
@ -1475,7 +1475,7 @@ class RegexStringWidget(StringWidget):
|
|||
if self.value is not None:
|
||||
try:
|
||||
re.compile(self.value)
|
||||
except:
|
||||
except Exception:
|
||||
self.error = _('invalid regular expression')
|
||||
self.value = None
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ def is_idp_managing_user_roles():
|
|||
def get_file_content(filename):
|
||||
try:
|
||||
return open(filename, 'r').read()
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
|
@ -455,7 +455,7 @@ class AdminIDPDir(Directory):
|
|||
rfd = misc.urlopen(metadata_url)
|
||||
except misc.ConnectionError as e:
|
||||
form.set_error('metadata_url', _('Failed to retrieve file (%s)') % e)
|
||||
except:
|
||||
except Exception:
|
||||
form.set_error('metadata_url', _('Failed to retrieve file'))
|
||||
else:
|
||||
s = rfd.read()
|
||||
|
@ -482,7 +482,7 @@ class AdminIDPDir(Directory):
|
|||
rfd = misc.urlopen(publickey_url)
|
||||
except misc.ConnectionError as e:
|
||||
form.set_error('metadata_url', _('Failed to retrieve file (%s)') % e)
|
||||
except:
|
||||
except Exception:
|
||||
form.set_error('publickey_url', _('Failed to retrieve file'))
|
||||
else:
|
||||
s = rfd.read()
|
||||
|
@ -627,7 +627,7 @@ class AdminIDPUI(Directory):
|
|||
metadata = open(misc.get_abs_path(self.idp['metadata'])).read()
|
||||
try:
|
||||
t = metadata.decode(str('utf8')).encode(get_publisher().site_charset)
|
||||
except:
|
||||
except Exception:
|
||||
t = metadata
|
||||
r += htmltext(t)
|
||||
r += htmltext('</pre>')
|
||||
|
@ -664,7 +664,7 @@ class AdminIDPUI(Directory):
|
|||
# this is an empty test to refer to p.providerId and raise an
|
||||
# exception if it is not available
|
||||
pass
|
||||
except:
|
||||
except Exception:
|
||||
p = None
|
||||
form = Form(enctype='multipart/form-data')
|
||||
form.widgets.append(
|
||||
|
@ -1057,7 +1057,7 @@ class MethodAdminDirectory(Directory):
|
|||
def get_key(name):
|
||||
try:
|
||||
return form.get_widget(name).parse().fp.read()
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
signing_pem_key = get_key('publickey')
|
||||
|
|
|
@ -286,7 +286,7 @@ class MethodDirectory(Directory):
|
|||
|
||||
try:
|
||||
user = PasswordAccount.get_with_credentials(username, password)
|
||||
except:
|
||||
except Exception:
|
||||
form.set_error('username', _('Invalid credentials'))
|
||||
return
|
||||
|
||||
|
|
|
@ -678,7 +678,7 @@ def get_thumbnail(filepath, content_type=None):
|
|||
image = Image.open(fp)
|
||||
try:
|
||||
exif = image._getexif()
|
||||
except:
|
||||
except Exception:
|
||||
exif = None
|
||||
|
||||
if exif:
|
||||
|
|
|
@ -247,7 +247,7 @@ class QommonPublisher(Publisher, object):
|
|||
if len(repr_value) > 10000:
|
||||
repr_value = repr_value[:10000] + ' [...]'
|
||||
print(repr_value, file=error_file)
|
||||
except:
|
||||
except Exception:
|
||||
print("<ERROR WHILE PRINTING VALUE>", file=error_file)
|
||||
print('', file=error_file)
|
||||
frame = frame.f_back
|
||||
|
@ -335,7 +335,7 @@ class QommonPublisher(Publisher, object):
|
|||
return output
|
||||
try:
|
||||
return self.render_response(output)
|
||||
except:
|
||||
except Exception:
|
||||
# Something went wrong applying the template, maybe an error in it;
|
||||
# fail the request properly, to get the error into the logs, the
|
||||
# trace sent by email, etc.
|
||||
|
@ -366,7 +366,7 @@ class QommonPublisher(Publisher, object):
|
|||
return
|
||||
try:
|
||||
self.site_options.read(site_options_filename, encoding='utf-8')
|
||||
except:
|
||||
except Exception:
|
||||
self.get_app_logger().error('failed to read site options file')
|
||||
return
|
||||
|
||||
|
@ -725,7 +725,7 @@ class QommonPublisher(Publisher, object):
|
|||
try:
|
||||
with open(filename, 'rb') as fd:
|
||||
self.cfg = pickle.load(fd, encoding='utf-8')
|
||||
except:
|
||||
except Exception:
|
||||
self.cfg = {}
|
||||
|
||||
def process(self, stdin, env):
|
||||
|
|
|
@ -427,7 +427,7 @@ class Saml2Directory(Directory):
|
|||
lasso_session = lasso.Session.newFromDump(session.lasso_session_dump)
|
||||
try:
|
||||
assertion = lasso_session.getAssertions(None)[0]
|
||||
except:
|
||||
except Exception:
|
||||
get_logger().warning('no assertion')
|
||||
return None
|
||||
|
||||
|
@ -702,7 +702,7 @@ class Saml2Directory(Directory):
|
|||
def singleLogoutSOAP(self):
|
||||
try:
|
||||
soap_message = self.get_soap_message()
|
||||
except:
|
||||
except Exception:
|
||||
return
|
||||
return self.slo_idp(soap_message, soap=True)
|
||||
|
||||
|
@ -750,7 +750,7 @@ class Saml2Directory(Directory):
|
|||
assertion.authnStatement[0].sessionIndex not in logout.request.sessionIndexes
|
||||
):
|
||||
logout.session.removeAssertion(logout.remoteProviderId)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
|
|
|
@ -678,7 +678,7 @@ class StorableObject(object):
|
|||
with locket.lock_file(objects_dir + '.lock.index'):
|
||||
try:
|
||||
self.update_indexes(previous_object_value, relative_object_filename)
|
||||
except:
|
||||
except Exception:
|
||||
# something failed, we can't keep using possibly broken indexes, so
|
||||
# we notify of the bug and remove the indexes
|
||||
get_publisher().notify_of_exception(sys.exc_info(), context='[STORAGE]')
|
||||
|
|
|
@ -106,7 +106,7 @@ def get_themes_dict():
|
|||
def get_theme_dict(theme_xml):
|
||||
try:
|
||||
tree = ET.parse(theme_xml).getroot()
|
||||
except: # parse error
|
||||
except Exception: # parse error
|
||||
return None
|
||||
name = force_str(tree.attrib['name'])
|
||||
version = force_str(tree.attrib.get('version') or '')
|
||||
|
@ -300,7 +300,7 @@ def get_decorate_vars(body, response, generate_breadcrumb=True, **kwargs):
|
|||
|
||||
try:
|
||||
user = get_request().user
|
||||
except:
|
||||
except Exception:
|
||||
user = None
|
||||
|
||||
if type(user) in (int, str) and get_session():
|
||||
|
|
|
@ -111,7 +111,7 @@ class _LockSet(object):
|
|||
for lock in self._locks:
|
||||
lock.acquire()
|
||||
acquired_locks.append(lock)
|
||||
except:
|
||||
except Exception:
|
||||
for acquired_lock in reversed(acquired_locks):
|
||||
# TODO: handle exceptions
|
||||
acquired_lock.release()
|
||||
|
|
|
@ -602,7 +602,7 @@ class ExportToModel(WorkflowStatusItem):
|
|||
# variable image
|
||||
try:
|
||||
variable_image = self.compute(name)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
if not hasattr(variable_image, 'get_content'):
|
||||
continue
|
||||
|
|
|
@ -123,7 +123,7 @@ class RegisterCommenterWorkflowStatusItem(WorkflowStatusItem):
|
|||
# needed by AttachmentEvolutionPart.from_upload()
|
||||
upload.get_file_pointer()
|
||||
formdata.evolution[-1].add_part(AttachmentEvolutionPart.from_upload(upload))
|
||||
except:
|
||||
except Exception:
|
||||
get_publisher().notify_of_exception(sys.exc_info(), context='[comment/attachments]')
|
||||
continue
|
||||
|
||||
|
|
|
@ -658,7 +658,7 @@ class Workflow(StorableObject):
|
|||
def import_from_xml(cls, fd, include_id=False, check_datasources=True):
|
||||
try:
|
||||
tree = ET.parse(fd)
|
||||
except:
|
||||
except Exception:
|
||||
raise ValueError()
|
||||
return cls.import_from_xml_tree(tree, include_id=include_id, check_datasources=check_datasources)
|
||||
|
||||
|
@ -1322,7 +1322,7 @@ class WorkflowGlobalActionTimeoutTrigger(WorkflowGlobalActionTrigger):
|
|||
variables = get_publisher().substitutions.get_context_variables()
|
||||
try:
|
||||
anchor_date = eval(self.anchor_expression, get_publisher().get_global_eval_dict(), variables)
|
||||
except:
|
||||
except Exception:
|
||||
# get the variables in the locals() namespace so they are
|
||||
# displayed within the trace.
|
||||
expression = self.anchor_expression # noqa pylint: disable=W0612
|
||||
|
@ -2316,7 +2316,7 @@ class WorkflowStatusItem(XmlSerialisable):
|
|||
|
||||
try:
|
||||
attachment = WorkflowStatusItem.compute(attachment, allow_complex=True, raises=True)
|
||||
except:
|
||||
except Exception:
|
||||
get_publisher().notify_of_exception(sys.exc_info(), context='[workflow/attachments]')
|
||||
else:
|
||||
if attachment:
|
||||
|
@ -2337,7 +2337,7 @@ class WorkflowStatusItem(XmlSerialisable):
|
|||
# execute any Python expression
|
||||
# and magically convert string like 'form_var_*_raw' to a PicklableUpload
|
||||
picklableupload = eval(attachment, global_eval_dict, local_eval_dict)
|
||||
except:
|
||||
except Exception:
|
||||
get_publisher().notify_of_exception(sys.exc_info(), context='[workflow/attachments]')
|
||||
continue
|
||||
|
||||
|
@ -2940,7 +2940,7 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem):
|
|||
for dest in self.to:
|
||||
try:
|
||||
dest = self.compute(dest, raises=True)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
if not dest:
|
||||
|
|
|
@ -102,7 +102,7 @@ def call_webservice(
|
|||
try:
|
||||
value = WorkflowStatusItem.compute(value, raises=True)
|
||||
value = str(value)
|
||||
except:
|
||||
except Exception:
|
||||
get_publisher().notify_of_exception(sys.exc_info())
|
||||
else:
|
||||
key = force_str(key)
|
||||
|
@ -133,7 +133,7 @@ def call_webservice(
|
|||
for (key, value) in post_data.items():
|
||||
try:
|
||||
payload[key] = WorkflowStatusItem.compute(value, allow_complex=True, raises=True)
|
||||
except:
|
||||
except Exception:
|
||||
get_publisher().notify_of_exception(sys.exc_info())
|
||||
else:
|
||||
if payload[key]:
|
||||
|
|
Loading…
Reference in New Issue