mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Merge branch 'fix_857_bad_logs_for_noworkingmirrorerrors' into develop
Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
This commit is contained in:
commit
4eeb5b4ea0
1 changed files with 80 additions and 12 deletions
|
|
@ -60,8 +60,14 @@ def __init__(self, exception):
|
|||
self.exception = exception
|
||||
|
||||
def __str__(self):
|
||||
return repr(self)
|
||||
|
||||
def __repr__(self):
|
||||
# Show the original exception.
|
||||
return repr(self.exception)
|
||||
return self.__class__.__name__ + ' : wraps error: ' + repr(self.exception)
|
||||
|
||||
# # Directly instance-reproducing:
|
||||
# return self.__class__.__name__ + '(' + repr(self.exception) + ')'
|
||||
|
||||
|
||||
class UnsupportedAlgorithmError(Error):
|
||||
|
|
@ -69,7 +75,7 @@ class UnsupportedAlgorithmError(Error):
|
|||
|
||||
|
||||
class BadHashError(Error):
|
||||
"""Indicate an error while checking the value a hash object."""
|
||||
"""Indicate an error while checking the value of a hash object."""
|
||||
|
||||
def __init__(self, expected_hash, observed_hash):
|
||||
super(BadHashError, self).__init__()
|
||||
|
|
@ -78,8 +84,19 @@ def __init__(self, expected_hash, observed_hash):
|
|||
self.observed_hash = observed_hash
|
||||
|
||||
def __str__(self):
|
||||
return 'Observed hash (' + repr(self.observed_hash)+\
|
||||
') != expected hash (' + repr(self.expected_hash)+')'
|
||||
return (
|
||||
'Observed hash (' + repr(self.observed_hash) + ') != expected hash (' +
|
||||
repr(self.expected_hash) + ')')
|
||||
|
||||
def __repr__(self):
|
||||
return self.__class__.__name__ + ' : ' + str(self)
|
||||
|
||||
# # Directly instance-reproducing:
|
||||
# return (
|
||||
# self.__class__.__name__ + '(' + repr(self.expected_hash) + ', ' +
|
||||
# repr(self.observed_hash) + ')')
|
||||
|
||||
|
||||
|
||||
|
||||
class BadVersionNumberError(Error):
|
||||
|
|
@ -122,9 +139,19 @@ def __init__(self, metadata_role, previous_version, current_version):
|
|||
|
||||
|
||||
def __str__(self):
|
||||
return 'Downloaded ' + repr(self.metadata_role)+' is older ('+\
|
||||
repr(self.previous_version) + ') than the version currently '+\
|
||||
'installed (' + repr(self.current_version) + ').'
|
||||
return (
|
||||
'Downloaded ' + repr(self.metadata_role) + ' is older (' +
|
||||
repr(self.previous_version) + ') than the version currently '
|
||||
'installed (' + repr(self.current_version) + ').')
|
||||
|
||||
def __repr__(self):
|
||||
return self.__class__.__name__ + ' : ' + str(self)
|
||||
|
||||
# # Directly instance-reproducing:
|
||||
# return (
|
||||
# self.__class__.__name__ + '(' + repr(self.metadata_role) + ', ' +
|
||||
# repr(self.previous_version) + ', ' + repr(self.current_version) + ')')
|
||||
|
||||
|
||||
|
||||
class CryptoError(Error):
|
||||
|
|
@ -140,7 +167,14 @@ def __init__(self, metadata_role_name):
|
|||
self.metadata_role_name = metadata_role_name
|
||||
|
||||
def __str__(self):
|
||||
return repr(self.metadata_role_name) + ' metadata has bad signature.'
|
||||
return repr(self.metadata_role_name) + ' metadata has a bad signature.'
|
||||
|
||||
def __repr__(self):
|
||||
return self.__class__.__name__ + ' : ' + str(self)
|
||||
|
||||
# # Directly instance-reproducing:
|
||||
# return (
|
||||
# self.__class__.__name__ + '(' + repr(self.metadata_role_name) + ')')
|
||||
|
||||
|
||||
class UnknownMethodError(CryptoError):
|
||||
|
|
@ -165,8 +199,18 @@ def __init__(self, expected_length, observed_length):
|
|||
self.observed_length = observed_length #bytes
|
||||
|
||||
def __str__(self):
|
||||
return 'Observed length (' + repr(self.observed_length) + \
|
||||
') < expected length (' + repr(self.expected_length) + ').'
|
||||
return (
|
||||
'Observed length (' + repr(self.observed_length) +
|
||||
') < expected length (' + repr(self.expected_length) + ').')
|
||||
|
||||
def __repr__(self):
|
||||
return self.__class__.__name__ + ' : ' + str(self)
|
||||
|
||||
# # Directly instance-reproducing:
|
||||
# return (
|
||||
# self.__class__.__name__ + '(' + repr(self.expected_length) + ', ' +
|
||||
# self.observed_length + ')')
|
||||
|
||||
|
||||
|
||||
class SlowRetrievalError(DownloadError):
|
||||
|
|
@ -178,8 +222,16 @@ def __init__(self, average_download_speed):
|
|||
self.__average_download_speed = average_download_speed #bytes/second
|
||||
|
||||
def __str__(self):
|
||||
return 'Download was too slow. Average speed: ' +\
|
||||
repr(self.__average_download_speed) + ' bytes per second.'
|
||||
return (
|
||||
'Download was too slow. Average speed: ' +
|
||||
repr(self.__average_download_speed) + ' bytes per second.')
|
||||
|
||||
def __repr__(self):
|
||||
return self.__class__.__name__ + ' : ' + str(self)
|
||||
|
||||
# # Directly instance-reproducing:
|
||||
# return (
|
||||
# self.__class__.__name__ + '(' + repr(self.__average_download_speed + ')')
|
||||
|
||||
|
||||
class KeyAlreadyExistsError(Error):
|
||||
|
|
@ -214,6 +266,14 @@ def __init__(self, message, signable):
|
|||
def __str__(self):
|
||||
return self.exception_message
|
||||
|
||||
def __repr__(self):
|
||||
return self.__class__.__name__ + ' : ' + str(self)
|
||||
|
||||
# # Directly instance-reproducing:
|
||||
# return (
|
||||
# self.__class__.__name__ + '(' + repr(self.exception_message) + ', ' +
|
||||
# repr(self.signable) + ')')
|
||||
|
||||
|
||||
class NoWorkingMirrorError(Error):
|
||||
"""
|
||||
|
|
@ -248,6 +308,14 @@ def __str__(self):
|
|||
|
||||
return all_errors
|
||||
|
||||
def __repr__(self):
|
||||
return self.__class__.__name__ + ' : ' + str(self)
|
||||
|
||||
# # Directly instance-reproducing:
|
||||
# return (
|
||||
# self.__class__.__name__ + '(' + repr(self.mirror_errors) + ')')
|
||||
|
||||
|
||||
|
||||
class NotFoundError(Error):
|
||||
"""If a required configuration or resource is not found."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue