Python errno.EDQUOT Examples

The following are 6 code examples of errno.EDQUOT(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module errno , or try the search function .
Example #1
Source File: sftp.py    From mock-ssh-server with MIT License 6 votes vote down vote up
def returns_sftp_error(func):

    def wrapped(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except OSError as err:
            LOG.debug("Error calling %s(%s, %s): %s",
                      func, args, kwargs, err, exc_info=True)
            errno = err.errno
            if errno in {EACCES, EDQUOT, EPERM, EROFS}:
                return paramiko.SFTP_PERMISSION_DENIED
            if errno in {ENOENT, ENOTDIR}:
                return paramiko.SFTP_NO_SUCH_FILE
            return paramiko.SFTP_FAILURE
        except Exception as err:
            LOG.debug("Error calling %s(%s, %s): %s",
                      func, args, kwargs, err, exc_info=True)
            return paramiko.SFTP_FAILURE

    return wrapped 
Example #2
Source File: test_filesystems_zfs.py    From flocker with Apache License 2.0 5 votes vote down vote up
def test_maximum_size_enforced(self):
        """
        The maximum size specified for a filesystem is enforced by the ZFS
        implementation.  Attempts to write more data than the maximum size
        fail.
        """
        pool = build_pool(self)
        service = service_for_pool(self, pool)
        # 40 MiB is an arbitrary value for the maximum size which is
        # sufficiently smaller than the current test pool size of 100 MiB.
        # Note that at the moment the usable pool size (minus the internal
        # data and reservations) is about 60 MiB.
        maximum_size = 40 * 1024 * 1024
        volume = service.get(
            MY_VOLUME, size=VolumeSize(maximum_size=maximum_size))
        creating = pool.create(volume)

        def write_and_flush(file_object, data):
            file_object.write(data)
            file_object.flush()

        def created(filesystem):
            path = filesystem.get_path()
            # Try to write one byte more than the maximum_size of data.
            with path.child(b"ok").open("w") as fObj:
                chunk_size = 8 * 1024
                chunk = b"x" * chunk_size
                for _ in range(maximum_size / chunk_size):
                    fObj.write(chunk)
                fObj.flush()
                exception = self.assertRaises(
                    IOError, write_and_flush, fObj, b'x')
                self.assertEqual(exception.args[0], errno.EDQUOT)

        creating.addCallback(created)
        return creating 
Example #3
Source File: _error_translation.py    From pyzfs with Apache License 2.0 5 votes vote down vote up
def lzc_receive_translate_error(ret, snapname, fd, force, origin, props):
    if ret == 0:
        return
    if ret == errno.EINVAL:
        if not _is_valid_snap_name(snapname) and not _is_valid_fs_name(snapname):
            raise lzc_exc.NameInvalid(snapname)
        elif len(snapname) > MAXNAMELEN:
            raise lzc_exc.NameTooLong(snapname)
        elif origin is not None and not _is_valid_snap_name(origin):
            raise lzc_exc.NameInvalid(origin)
        else:
            raise lzc_exc.BadStream()
    if ret == errno.ENOENT:
        if not _is_valid_snap_name(snapname):
            raise lzc_exc.NameInvalid(snapname)
        else:
            raise lzc_exc.DatasetNotFound(snapname)
    if ret == errno.EEXIST:
        raise lzc_exc.DatasetExists(snapname)
    if ret == errno.ENOTSUP:
        raise lzc_exc.StreamFeatureNotSupported()
    if ret == errno.ENODEV:
        raise lzc_exc.StreamMismatch(_fs_name(snapname))
    if ret == errno.ETXTBSY:
        raise lzc_exc.DestinationModified(_fs_name(snapname))
    if ret == errno.EBUSY:
        raise lzc_exc.DatasetBusy(_fs_name(snapname))
    if ret == errno.ENOSPC:
        raise lzc_exc.NoSpace(_fs_name(snapname))
    if ret == errno.EDQUOT:
        raise lzc_exc.QuotaExceeded(_fs_name(snapname))
    if ret == errno.ENAMETOOLONG:
        raise lzc_exc.NameTooLong(snapname)
    if ret == errno.EROFS:
        raise lzc_exc.ReadOnlyPool(_pool_name(snapname))
    if ret == errno.EAGAIN:
        raise lzc_exc.SuspendedPool(_pool_name(snapname))

    raise lzc_exc.StreamIOError(ret) 
Example #4
Source File: utils.py    From tvalacarta with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, code=None, msg='Unknown error'):
        super(XAttrMetadataError, self).__init__(msg)
        self.code = code
        self.msg = msg

        # Parsing code and msg
        if (self.code in (errno.ENOSPC, errno.EDQUOT)
                or 'No space left' in self.msg or 'Disk quota excedded' in self.msg):
            self.reason = 'NO_SPACE'
        elif self.code == errno.E2BIG or 'Argument list too long' in self.msg:
            self.reason = 'VALUE_TOO_LONG'
        else:
            self.reason = 'NOT_SUPPORTED' 
Example #5
Source File: utils.py    From youtube-dl-GUI with MIT License 5 votes vote down vote up
def __init__(self, code=None, msg='Unknown error'):
        super(XAttrMetadataError, self).__init__(msg)
        self.code = code
        self.msg = msg

        # Parsing code and msg
        if (self.code in (errno.ENOSPC, errno.EDQUOT) or
                'No space left' in self.msg or 'Disk quota excedded' in self.msg):
            self.reason = 'NO_SPACE'
        elif self.code == errno.E2BIG or 'Argument list too long' in self.msg:
            self.reason = 'VALUE_TOO_LONG'
        else:
            self.reason = 'NOT_SUPPORTED' 
Example #6
Source File: utils.py    From anime-dl with MIT License 5 votes vote down vote up
def __init__(self, code=None, msg='Unknown error'):
        super(XAttrMetadataError, self).__init__(msg)
        self.code = code
        self.msg = msg

        # Parsing code and msg
        if (self.code in (errno.ENOSPC, errno.EDQUOT) or
                'No space left' in self.msg or 'Disk quota excedded' in self.msg):
            self.reason = 'NO_SPACE'
        elif self.code == errno.E2BIG or 'Argument list too long' in self.msg:
            self.reason = 'VALUE_TOO_LONG'
        else:
            self.reason = 'NOT_SUPPORTED'