How to use the b2sdk.exception.B2SimpleError function in b2sdk

To help you get started, we’ve selected a few b2sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Backblaze / b2-sdk-python / b2sdk / exception.py View on Github external
self.source_file.name,
            self.source_file.latest_version().mod_time,
            self.dest_prefix,
            self.dest_file.name,
            self.dest_file.latest_version().mod_time,
        )

    def should_retry_http(self):
        return True


class DuplicateBucketName(B2SimpleError):
    prefix = 'Bucket name is already in use'


class FileAlreadyHidden(B2SimpleError):
    pass


class FileNameNotAllowed(NotAllowedByAppKeyError):
    pass


class FileNotPresent(B2SimpleError):
    pass


class UnusableFileName(B2SimpleError):
    """
    Raise when a filename doesn't meet the rules.

    Could possibly use InvalidUploadSource, but this is intended for the filename on the
github Backblaze / b2-sdk-python / b2sdk / exception.py View on Github external
class TruncatedOutput(TransientErrorMixin, B2Error):
    def __init__(self, bytes_read, file_size):
        super(TruncatedOutput, self).__init__()
        self.bytes_read = bytes_read
        self.file_size = file_size

    def __str__(self):
        return 'only %d of %d bytes read' % (
            self.bytes_read,
            self.file_size,
        )


class UnexpectedCloudBehaviour(B2SimpleError):
    pass


class UnknownError(B2SimpleError):
    pass


class UnknownHost(B2Error):
    def __str__(self):
        return 'unknown host'


class UnrecognizedBucketType(B2Error):
    pass
github Backblaze / b2-sdk-python / b2sdk / exception.py View on Github external
"""
        return False


@six.add_metaclass(ABCMeta)
class B2SimpleError(B2Error):
    """
    A B2Error with a message prefix.
    """

    def __str__(self):
        return '%s: %s' % (self.prefix, super(B2SimpleError, self).__str__())


@six.add_metaclass(ABCMeta)
class NotAllowedByAppKeyError(B2SimpleError):
    """
    Base class for errors caused by restrictions on an application key.
    """


@six.add_metaclass(ABCMeta)
class TransientErrorMixin(object):
    def should_retry_http(self):
        return True

    def should_retry_upload(self):
        return True


class AlreadyFailed(B2SimpleError):
    pass
github Backblaze / b2-sdk-python / b2sdk / exception.py View on Github external
return self.message


class Conflict(B2SimpleError):
    pass


class ConnectionReset(B2Error):
    def __str__(self):
        return 'Connection reset'

    def should_retry_upload(self):
        return True


class B2ConnectionError(TransientErrorMixin, B2SimpleError):
    pass


class B2RequestTimeout(TransientErrorMixin, B2SimpleError):
    pass


class B2RequestTimeoutDuringUpload(B2RequestTimeout):
    # if a timeout is hit during upload, it is not guaranteed that the the server has released the upload token lock already, so we'll use a new token
    def should_retry_http(self):
        return False


class DestFileNewer(B2Error):
    def __init__(self, dest_file, source_file, dest_prefix, source_prefix):
        super(DestFileNewer, self).__init__()
github Backblaze / b2-sdk-python / b2sdk / exception.py View on Github external
def __str__(self):
        return '%s: %s' % (self.prefix, super(B2SimpleError, self).__str__())
github Backblaze / b2-sdk-python / b2sdk / exception.py View on Github external
prefix = 'Bucket name is already in use'


class FileAlreadyHidden(B2SimpleError):
    pass


class FileNameNotAllowed(NotAllowedByAppKeyError):
    pass


class FileNotPresent(B2SimpleError):
    pass


class UnusableFileName(B2SimpleError):
    """
    Raise when a filename doesn't meet the rules.

    Could possibly use InvalidUploadSource, but this is intended for the filename on the
    server, which could differ.  https://www.backblaze.com/b2/docs/files.html.
    """
    pass


class InvalidMetadataDirective(B2Error):
    pass


class InvalidRange(B2Error):
    def __init__(self, content_length, range_):
        super(InvalidRange, self).__init__()
github Backblaze / b2-sdk-python / b2sdk / exception.py View on Github external
class InvalidRange(B2Error):
    def __init__(self, content_length, range_):
        super(InvalidRange, self).__init__()
        self.content_length = content_length
        self.range_ = range_

    def __str__(self):
        return 'A range of %d-%d was requested (size of %d), but cloud could only serve %d of that' % (
            self.range_[0],
            self.range_[1],
            self.range_[1] - self.range_[0] + 1,
            self.content_length,
        )


class InvalidUploadSource(B2SimpleError):
    pass


class BadRequest(B2Error):
    def __init__(self, message, code):
        super(BadRequest, self).__init__()
        self.message = message
        self.code = code

    def __str__(self):
        return '%s (%s)' % (self.message, self.code)


class Unauthorized(B2Error):
    def __init__(self, message, code):
        super(Unauthorized, self).__init__()
github Backblaze / b2-sdk-python / b2sdk / exception.py View on Github external
class MaxRetriesExceeded(B2Error):
    def __init__(self, limit, exception_info_list):
        super(MaxRetriesExceeded, self).__init__()
        self.limit = limit
        self.exception_info_list = exception_info_list

    def __str__(self):
        exceptions = '\n'.join(str(wrapped_error) for wrapped_error in self.exception_info_list)
        return 'FAILED to upload after %s tries. Encountered exceptions: %s' % (
            self.limit,
            exceptions,
        )


class MissingPart(B2SimpleError):
    prefix = 'Part number has not been uploaded'


class NonExistentBucket(B2SimpleError):
    prefix = 'No such bucket'


class FileSha1Mismatch(B2SimpleError):
    prefix = 'Upload file SHA1 mismatch'


class PartSha1Mismatch(B2Error):
    def __init__(self, key):
        super(PartSha1Mismatch, self).__init__()
        self.key = key
github Backblaze / b2-sdk-python / b2sdk / sync / exception.py View on Github external
"""

    def __init__(self, parameter_name, message):
        """
        :param parameter_name: name of the function argument
        :param message: brief explanation of misconfiguration
        """
        super(InvalidArgument, self).__init__()
        self.parameter_name = parameter_name
        self.message = message

    def __str__(self):
        return "%s %s" % (self.parameter_name, self.message)


class IncompleteSync(B2SimpleError):
    pass


class UnSyncableFilename(B2Error):
    """
    Raised when a filename is not supported by the sync operation
    """

    def __init__(self, message, filename):
        """
        :param message: brief explanation of why the filename was not supported
        :param filename: name of the file which is not supported
        """
        super(UnSyncableFilename, self).__init__()
        self.filename = filename
        self.message = message
github Backblaze / b2-sdk-python / b2sdk / exception.py View on Github external
self.limit = limit
        self.exception_info_list = exception_info_list

    def __str__(self):
        exceptions = '\n'.join(str(wrapped_error) for wrapped_error in self.exception_info_list)
        return 'FAILED to upload after %s tries. Encountered exceptions: %s' % (
            self.limit,
            exceptions,
        )


class MissingPart(B2SimpleError):
    prefix = 'Part number has not been uploaded'


class NonExistentBucket(B2SimpleError):
    prefix = 'No such bucket'


class FileSha1Mismatch(B2SimpleError):
    prefix = 'Upload file SHA1 mismatch'


class PartSha1Mismatch(B2Error):
    def __init__(self, key):
        super(PartSha1Mismatch, self).__init__()
        self.key = key

    def __str__(self):
        return 'Part number %s has wrong SHA1' % (self.key,)