mirror of https://github.com/OpenKMIP/PyKMIP.git
Fixing violations of E722 for flake8 checks
This change fixes violations of E722, the use of except without specifying an exception type. For now the high-level Exception class is used as a generic catchall. In the future these cases will be updated to handle the specific exceptions expected.
This commit is contained in:
parent
626798b327
commit
e77dcadf41
|
@ -83,7 +83,7 @@ class ConfigHelper(object):
|
|||
self.logger.debug(CONF_MSG.format(return_value,
|
||||
CONFIG_FILE,
|
||||
config_option_name))
|
||||
except:
|
||||
except Exception:
|
||||
return_value = default_value
|
||||
self.logger.debug(DEFAULT_MSG.format(default_value,
|
||||
config_option_name))
|
||||
|
|
|
@ -678,7 +678,7 @@ class Boolean(Base):
|
|||
"""
|
||||
try:
|
||||
value = unpack('!Q', istream.read(self.LENGTH))[0]
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.error("Error reading boolean value from buffer")
|
||||
raise
|
||||
|
||||
|
@ -713,7 +713,7 @@ class Boolean(Base):
|
|||
"""
|
||||
try:
|
||||
ostream.write(pack('!Q', self.value))
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.error("Error writing boolean value to buffer")
|
||||
raise
|
||||
|
||||
|
|
|
@ -357,11 +357,11 @@ class KMIPProxy(KMIP):
|
|||
result['result_status'] = batch_item.result_status.value
|
||||
try:
|
||||
result['result_reason'] = batch_item.result_reason.value
|
||||
except:
|
||||
except Exception:
|
||||
result['result_reason'] = batch_item.result_reason
|
||||
try:
|
||||
result['result_message'] = batch_item.result_message.value
|
||||
except:
|
||||
except Exception:
|
||||
result['result_message'] = batch_item.result_message
|
||||
|
||||
return result
|
||||
|
@ -571,11 +571,11 @@ class KMIPProxy(KMIP):
|
|||
result['result_status'] = batch_item.result_status.value
|
||||
try:
|
||||
result['result_reason'] = batch_item.result_reason.value
|
||||
except:
|
||||
except Exception:
|
||||
result['result_reason'] = batch_item.result_reason
|
||||
try:
|
||||
result['result_message'] = batch_item.result_message.value
|
||||
except:
|
||||
except Exception:
|
||||
result['result_message'] = batch_item.result_message
|
||||
|
||||
return result
|
||||
|
@ -646,11 +646,11 @@ class KMIPProxy(KMIP):
|
|||
result['result_status'] = batch_item.result_status.value
|
||||
try:
|
||||
result['result_reason'] = batch_item.result_reason.value
|
||||
except:
|
||||
except Exception:
|
||||
result['result_reason'] = batch_item.result_reason
|
||||
try:
|
||||
result['result_message'] = batch_item.result_message.value
|
||||
except:
|
||||
except Exception:
|
||||
result['result_message'] = batch_item.result_message
|
||||
|
||||
return result
|
||||
|
@ -721,11 +721,11 @@ class KMIPProxy(KMIP):
|
|||
result['result_status'] = batch_item.result_status.value
|
||||
try:
|
||||
result['result_reason'] = batch_item.result_reason.value
|
||||
except:
|
||||
except Exception:
|
||||
result['result_reason'] = batch_item.result_reason
|
||||
try:
|
||||
result['result_message'] = batch_item.result_message.value
|
||||
except:
|
||||
except Exception:
|
||||
result['result_message'] = batch_item.result_message
|
||||
|
||||
return result
|
||||
|
@ -787,11 +787,11 @@ class KMIPProxy(KMIP):
|
|||
result['result_status'] = batch_item.result_status.value
|
||||
try:
|
||||
result['result_reason'] = batch_item.result_reason.value
|
||||
except:
|
||||
except Exception:
|
||||
result['result_reason'] = batch_item.result_reason
|
||||
try:
|
||||
result['result_message'] = batch_item.result_message.value
|
||||
except:
|
||||
except Exception:
|
||||
result['result_message'] = batch_item.result_message
|
||||
|
||||
return result
|
||||
|
|
|
@ -1208,7 +1208,7 @@ class CryptographyEngine(api.CryptographicEngine):
|
|||
backend=default_backend()
|
||||
)
|
||||
return private_key
|
||||
except:
|
||||
except Exception:
|
||||
private_key = serialization.load_der_private_key(
|
||||
bytes,
|
||||
password=None,
|
||||
|
@ -1271,7 +1271,7 @@ class CryptographyEngine(api.CryptographicEngine):
|
|||
if crypto_alg == enums.CryptographicAlgorithm.RSA:
|
||||
try:
|
||||
key = self._create_RSA_private_key(signing_key)
|
||||
except:
|
||||
except Exception:
|
||||
raise exceptions.InvalidField('Unable to deserialize key '
|
||||
'bytes, unknown format.')
|
||||
else:
|
||||
|
|
|
@ -2664,7 +2664,7 @@ def load_private_key(key):
|
|||
password=None,
|
||||
backend=default_backend()
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
return serialization.load_pem_private_key(
|
||||
key,
|
||||
password=None,
|
||||
|
|
|
@ -17,7 +17,7 @@ import logging
|
|||
|
||||
try:
|
||||
import unittest.mock as mock
|
||||
except:
|
||||
except Exception:
|
||||
import mock
|
||||
|
||||
import signal
|
||||
|
|
Loading…
Reference in New Issue