本文整理汇总了Python中errno.ENOTSUP属性的典型用法代码示例。如果您正苦于以下问题:Python errno.ENOTSUP属性的具体用法?Python errno.ENOTSUP怎么用?Python errno.ENOTSUP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类errno
的用法示例。
在下文中一共展示了errno.ENOTSUP属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _copyxattr
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def _copyxattr(src, dst, *, follow_symlinks=True):
"""Copy extended filesystem attributes from `src` to `dst`.
Overwrite existing attributes.
If `follow_symlinks` is false, symlinks won't be followed.
"""
try:
names = os.listxattr(src, follow_symlinks=follow_symlinks)
except OSError as e:
if e.errno not in (errno.ENOTSUP, errno.ENODATA):
raise
return
for name in names:
try:
value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
except OSError as e:
if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA):
raise
示例2: test_copystat_handles_harmless_chflags_errors
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def test_copystat_handles_harmless_chflags_errors(self):
tmpdir = self.mkdtemp()
file1 = os.path.join(tmpdir, 'file1')
file2 = os.path.join(tmpdir, 'file2')
self.write_file(file1, 'xxx')
self.write_file(file2, 'xxx')
def make_chflags_raiser(err):
ex = OSError()
def _chflags_raiser(path, flags):
ex.errno = err
raise ex
return _chflags_raiser
old_chflags = os.chflags
try:
for err in errno.EOPNOTSUPP, errno.ENOTSUP:
os.chflags = make_chflags_raiser(err)
shutil.copystat(file1, file2)
# assert others errors break it
os.chflags = make_chflags_raiser(errno.EOPNOTSUPP + errno.ENOTSUP)
self.assertRaises(OSError, shutil.copystat, file1, file2)
finally:
os.chflags = old_chflags
示例3: test_copystat_handles_harmless_chflags_errors
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def test_copystat_handles_harmless_chflags_errors(self):
tmpdir = self.mkdtemp()
file1 = os.path.join(tmpdir, 'file1')
file2 = os.path.join(tmpdir, 'file2')
write_file(file1, 'xxx')
write_file(file2, 'xxx')
def make_chflags_raiser(err):
ex = OSError()
def _chflags_raiser(path, flags, *, follow_symlinks=True):
ex.errno = err
raise ex
return _chflags_raiser
old_chflags = os.chflags
try:
for err in errno.EOPNOTSUPP, errno.ENOTSUP:
os.chflags = make_chflags_raiser(err)
shutil.copystat(file1, file2)
# assert others errors break it
os.chflags = make_chflags_raiser(errno.EOPNOTSUPP + errno.ENOTSUP)
self.assertRaises(OSError, shutil.copystat, file1, file2)
finally:
os.chflags = old_chflags
示例4: _copyxattr
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def _copyxattr(src, dst, *, follow_symlinks=True):
"""Copy extended filesystem attributes from `src` to `dst`.
Overwrite existing attributes.
If `follow_symlinks` is false, symlinks won't be followed.
"""
try:
names = os.listxattr(src, follow_symlinks=follow_symlinks)
except OSError as e:
if e.errno not in (errno.ENOTSUP, errno.ENODATA, errno.EINVAL):
raise
return
for name in names:
try:
value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
except OSError as e:
if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA,
errno.EINVAL):
raise
示例5: _get_range_info
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def _get_range_info(interface, sock=None):
interface = _get_bytes(interface)
range = ffi.new('struct iw_range *')
with iwlib_socket(sock=sock) as sock:
has_range = iwlib.iw_get_range_info(sock, interface, range) >= 0
if not has_range or range.we_version_compiled < 14:
err = errno.ENOTSUP
raise OSError(err, os.strerror(err))
return range
示例6: listen
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def listen(self, backlog):
with self.lock:
if self.state.SHUTDOWN:
raise err.Error(errno.ESHUTDOWN)
if not self.state.CLOSED:
self.err("listen() but socket state is {0}".format(self.state))
raise err.Error(errno.ENOTSUP)
self.state.LISTEN = True
self.recv_buf = backlog
示例7: test_listen
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def test_listen(self, tco):
tco.listen(backlog=1)
assert tco.state.LISTEN is True
with pytest.raises(nfc.llcp.Error) as excinfo:
tco.listen(1)
assert excinfo.value.errno == errno.ENOTSUP
tco.close()
with pytest.raises(nfc.llcp.Error) as excinfo:
tco.listen(1)
assert excinfo.value.errno == errno.ESHUTDOWN
示例8: lzc_bookmark_translate_errors
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def lzc_bookmark_translate_errors(ret, errlist, bookmarks):
if ret == 0:
return
def _map(ret, name):
if ret == errno.EINVAL:
if name:
snap = bookmarks[name]
pool_names = map(_pool_name, bookmarks.keys())
if not _is_valid_bmark_name(name):
return lzc_exc.BookmarkNameInvalid(name)
elif not _is_valid_snap_name(snap):
return lzc_exc.SnapshotNameInvalid(snap)
elif _fs_name(name) != _fs_name(snap):
return lzc_exc.BookmarkMismatch(name)
elif any(x != _pool_name(name) for x in pool_names):
return lzc_exc.PoolsDiffer(name)
else:
invalid_names = [b for b in bookmarks.keys() if not _is_valid_bmark_name(b)]
if invalid_names:
return lzc_exc.BookmarkNameInvalid(invalid_names[0])
if ret == errno.EEXIST:
return lzc_exc.BookmarkExists(name)
if ret == errno.ENOENT:
return lzc_exc.SnapshotNotFound(name)
if ret == errno.ENOTSUP:
return lzc_exc.BookmarkNotSupported(name)
return _generic_exception(ret, name, "Failed to create bookmark")
_handle_err_list(ret, errlist, bookmarks.keys(), lzc_exc.BookmarkFailure, _map)
示例9: lzc_hold_translate_errors
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def lzc_hold_translate_errors(ret, errlist, holds, fd):
if ret == 0:
return
def _map(ret, name):
if ret == errno.EXDEV:
return lzc_exc.PoolsDiffer(name)
elif ret == errno.EINVAL:
if name:
pool_names = map(_pool_name, holds.keys())
if not _is_valid_snap_name(name):
return lzc_exc.NameInvalid(name)
elif len(name) > MAXNAMELEN:
return lzc_exc.NameTooLong(name)
elif any(x != _pool_name(name) for x in pool_names):
return lzc_exc.PoolsDiffer(name)
else:
invalid_names = [b for b in holds.keys() if not _is_valid_snap_name(b)]
if invalid_names:
return lzc_exc.NameInvalid(invalid_names[0])
fs_name = None
hold_name = None
pool_name = None
if name is not None:
fs_name = _fs_name(name)
pool_name = _pool_name(name)
hold_name = holds[name]
if ret == errno.ENOENT:
return lzc_exc.FilesystemNotFound(fs_name)
if ret == errno.EEXIST:
return lzc_exc.HoldExists(name)
if ret == errno.E2BIG:
return lzc_exc.NameTooLong(hold_name)
if ret == errno.ENOTSUP:
return lzc_exc.FeatureNotSupported(pool_name)
return _generic_exception(ret, name, "Failed to hold snapshot")
if ret == errno.EBADF:
raise lzc_exc.BadHoldCleanupFD()
_handle_err_list(ret, errlist, holds.keys(), lzc_exc.HoldFailure, _map)
示例10: lzc_release_translate_errors
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def lzc_release_translate_errors(ret, errlist, holds):
if ret == 0:
return
for _, hold_list in holds.iteritems():
if not isinstance(hold_list, list):
raise lzc_exc.TypeError('holds must be in a list')
def _map(ret, name):
if ret == errno.EXDEV:
return lzc_exc.PoolsDiffer(name)
elif ret == errno.EINVAL:
if name:
pool_names = map(_pool_name, holds.keys())
if not _is_valid_snap_name(name):
return lzc_exc.NameInvalid(name)
elif len(name) > MAXNAMELEN:
return lzc_exc.NameTooLong(name)
elif any(x != _pool_name(name) for x in pool_names):
return lzc_exc.PoolsDiffer(name)
else:
invalid_names = [b for b in holds.keys() if not _is_valid_snap_name(b)]
if invalid_names:
return lzc_exc.NameInvalid(invalid_names[0])
elif ret == errno.ENOENT:
return lzc_exc.HoldNotFound(name)
elif ret == errno.E2BIG:
tag_list = holds[name]
too_long_tags = [t for t in tag_list if len(t) > MAXNAMELEN]
return lzc_exc.NameTooLong(too_long_tags[0])
elif ret == errno.ENOTSUP:
pool_name = None
if name is not None:
pool_name = _pool_name(name)
return lzc_exc.FeatureNotSupported(pool_name)
else:
return _generic_exception(ret, name, "Failed to release snapshot hold")
_handle_err_list(ret, errlist, holds.keys(), lzc_exc.HoldReleaseFailure, _map)
示例11: lzc_get_holds_translate_error
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def lzc_get_holds_translate_error(ret, snapname):
if ret == 0:
return
if ret == errno.EINVAL:
_validate_snap_name(snapname)
if ret == errno.ENOENT:
raise lzc_exc.SnapshotNotFound(snapname)
if ret == errno.ENOTSUP:
raise lzc_exc.FeatureNotSupported(_pool_name(snapname))
raise _generic_exception(ret, snapname, "Failed to get holds on snapshot")
示例12: lzc_receive_translate_error
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
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)
示例13: truncate
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def truncate(self, path, size, fh=None):
if size == 0:
fh = self._open(path, "wb")
self.filehandles[fh][0].method("close")
self.filehandles[fh] = None
else:
# not implemented
raise fuse.FuseOSError(errno.ENOTSUP)
示例14: rename
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTSUP [as 别名]
def rename(self, id_p_old, name_old, id_p_new, name_new, flags, ctx):
if flags:
raise FUSEError(errno.ENOTSUP)
log.debug('started with %d, %r, %d, %r', id_p_old, name_old, id_p_new, name_new)
if name_new == CTRL_NAME or name_old == CTRL_NAME:
log.warning('Attempted to rename s3ql control file (%s -> %s)',
get_path(id_p_old, self.db, name_old),
get_path(id_p_new, self.db, name_new))
raise FUSEError(errno.EACCES)
if (self.failsafe or self.inodes[id_p_old].locked
or self.inodes[id_p_new].locked):
raise FUSEError(errno.EPERM)
inode_old = self._lookup(id_p_old, name_old, ctx)
try:
inode_new = self._lookup(id_p_new, name_new, ctx)
except FUSEError as exc:
if exc.errno != errno.ENOENT:
raise
else:
target_exists = False
else:
target_exists = True
if target_exists:
self._replace(id_p_old, name_old, id_p_new, name_new,
inode_old.id, inode_new.id)
await self.forget([(inode_old.id, 1), (inode_new.id, 1)])
else:
self._rename(id_p_old, name_old, id_p_new, name_new)
await self.forget([(inode_old.id, 1)])