Python errno.ENODATA Examples
The following are 21
code examples of errno.ENODATA().
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: shutil.py From kobo-predict with BSD 2-Clause "Simplified" License | 7 votes |
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
Example #2
Source File: shutil.py From jawfish with MIT License | 7 votes |
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
Example #3
Source File: fsutils.py From uniconvertor with GNU Affero General Public License v3.0 | 6 votes |
def get_fileptr(path, writable=False): if not path: msg = _('There is no file path') raise IOError(errno.ENODATA, msg, '') path = get_sys_path(path) if writable: try: fileptr = open(path, 'wb') except Exception: msg = _('Cannot open %s file for writing') % path events.emit(events.MESSAGES, msgconst.ERROR, msg) LOG.exception(msg) raise else: try: fileptr = open(path, 'rb') except Exception: msg = _('Cannot open %s file for reading') % path events.emit(events.MESSAGES, msgconst.ERROR, msg) LOG.exception(msg) raise return fileptr
Example #4
Source File: generic_filters.py From uniconvertor with GNU Affero General Public License v3.0 | 6 votes |
def save(self, presenter, path=None, fileptr=None): self.presenter = presenter self.config = self.presenter.config self.model = presenter.model if path: self.fileptr = get_fileptr(path, True) elif fileptr: self.fileptr = fileptr else: msg = _('There is no file for writting') raise IOError(errno.ENODATA, msg, '') self.presenter.update() self.saving_msg(.01) try: self.do_save() except Exception as e: LOG.error('Error saving file content %s', e) raise self.saving_msg(.99) self.fileptr.close() self.fileptr = None
Example #5
Source File: shutil.py From android_universal with MIT License | 6 votes |
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
Example #6
Source File: shutil.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #7
Source File: shutil.py From odoo13-x64 with GNU General Public License v3.0 | 6 votes |
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
Example #8
Source File: shutil.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
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
Example #9
Source File: shutil.py From python2017 with MIT License | 6 votes |
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
Example #10
Source File: shutil.py From python with Apache License 2.0 | 6 votes |
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
Example #11
Source File: shutil.py From ironpython3 with Apache License 2.0 | 6 votes |
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
Example #12
Source File: shutil.py From scylla with Apache License 2.0 | 6 votes |
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
Example #13
Source File: shutil.py From Imogen with MIT License | 6 votes |
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
Example #14
Source File: shutil.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
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
Example #15
Source File: shutil.py From GraphicDesignPatternByPython with MIT License | 6 votes |
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
Example #16
Source File: test_os.py From ironpython3 with Apache License 2.0 | 5 votes |
def _check_xattrs_str(self, s, getxattr, setxattr, removexattr, listxattr, **kwargs): fn = support.TESTFN open(fn, "wb").close() with self.assertRaises(OSError) as cm: getxattr(fn, s("user.test"), **kwargs) self.assertEqual(cm.exception.errno, errno.ENODATA) init_xattr = listxattr(fn) self.assertIsInstance(init_xattr, list) setxattr(fn, s("user.test"), b"", **kwargs) xattr = set(init_xattr) xattr.add("user.test") self.assertEqual(set(listxattr(fn)), xattr) self.assertEqual(getxattr(fn, b"user.test", **kwargs), b"") setxattr(fn, s("user.test"), b"hello", os.XATTR_REPLACE, **kwargs) self.assertEqual(getxattr(fn, b"user.test", **kwargs), b"hello") with self.assertRaises(OSError) as cm: setxattr(fn, s("user.test"), b"bye", os.XATTR_CREATE, **kwargs) self.assertEqual(cm.exception.errno, errno.EEXIST) with self.assertRaises(OSError) as cm: setxattr(fn, s("user.test2"), b"bye", os.XATTR_REPLACE, **kwargs) self.assertEqual(cm.exception.errno, errno.ENODATA) setxattr(fn, s("user.test2"), b"foo", os.XATTR_CREATE, **kwargs) xattr.add("user.test2") self.assertEqual(set(listxattr(fn)), xattr) removexattr(fn, s("user.test"), **kwargs) with self.assertRaises(OSError) as cm: getxattr(fn, s("user.test"), **kwargs) self.assertEqual(cm.exception.errno, errno.ENODATA) xattr.remove("user.test") self.assertEqual(set(listxattr(fn)), xattr) self.assertEqual(getxattr(fn, s("user.test2"), **kwargs), b"foo") setxattr(fn, s("user.test"), b"a"*1024, **kwargs) self.assertEqual(getxattr(fn, s("user.test"), **kwargs), b"a"*1024) removexattr(fn, s("user.test"), **kwargs) many = sorted("user.test{}".format(i) for i in range(100)) for thing in many: setxattr(fn, thing, b"x", **kwargs) self.assertEqual(set(listxattr(fn)), set(init_xattr) | set(many))
Example #17
Source File: test_os.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def _check_xattrs_str(self, s, getxattr, setxattr, removexattr, listxattr, **kwargs): fn = support.TESTFN open(fn, "wb").close() with self.assertRaises(OSError) as cm: getxattr(fn, s("user.test"), **kwargs) self.assertEqual(cm.exception.errno, errno.ENODATA) init_xattr = listxattr(fn) self.assertIsInstance(init_xattr, list) setxattr(fn, s("user.test"), b"", **kwargs) xattr = set(init_xattr) xattr.add("user.test") self.assertEqual(set(listxattr(fn)), xattr) self.assertEqual(getxattr(fn, b"user.test", **kwargs), b"") setxattr(fn, s("user.test"), b"hello", os.XATTR_REPLACE, **kwargs) self.assertEqual(getxattr(fn, b"user.test", **kwargs), b"hello") with self.assertRaises(OSError) as cm: setxattr(fn, s("user.test"), b"bye", os.XATTR_CREATE, **kwargs) self.assertEqual(cm.exception.errno, errno.EEXIST) with self.assertRaises(OSError) as cm: setxattr(fn, s("user.test2"), b"bye", os.XATTR_REPLACE, **kwargs) self.assertEqual(cm.exception.errno, errno.ENODATA) setxattr(fn, s("user.test2"), b"foo", os.XATTR_CREATE, **kwargs) xattr.add("user.test2") self.assertEqual(set(listxattr(fn)), xattr) removexattr(fn, s("user.test"), **kwargs) with self.assertRaises(OSError) as cm: getxattr(fn, s("user.test"), **kwargs) self.assertEqual(cm.exception.errno, errno.ENODATA) xattr.remove("user.test") self.assertEqual(set(listxattr(fn)), xattr) self.assertEqual(getxattr(fn, s("user.test2"), **kwargs), b"foo") setxattr(fn, s("user.test"), b"a"*1024, **kwargs) self.assertEqual(getxattr(fn, s("user.test"), **kwargs), b"a"*1024) removexattr(fn, s("user.test"), **kwargs) many = sorted("user.test{}".format(i) for i in range(100)) for thing in many: setxattr(fn, thing, b"x", **kwargs) self.assertEqual(set(listxattr(fn)), set(init_xattr) | set(many))
Example #18
Source File: test_os.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def _check_xattrs_str(self, s, getxattr, setxattr, removexattr, listxattr, **kwargs): fn = support.TESTFN open(fn, "wb").close() with self.assertRaises(OSError) as cm: getxattr(fn, s("user.test"), **kwargs) self.assertEqual(cm.exception.errno, errno.ENODATA) init_xattr = listxattr(fn) self.assertIsInstance(init_xattr, list) setxattr(fn, s("user.test"), b"", **kwargs) xattr = set(init_xattr) xattr.add("user.test") self.assertEqual(set(listxattr(fn)), xattr) self.assertEqual(getxattr(fn, b"user.test", **kwargs), b"") setxattr(fn, s("user.test"), b"hello", os.XATTR_REPLACE, **kwargs) self.assertEqual(getxattr(fn, b"user.test", **kwargs), b"hello") with self.assertRaises(OSError) as cm: setxattr(fn, s("user.test"), b"bye", os.XATTR_CREATE, **kwargs) self.assertEqual(cm.exception.errno, errno.EEXIST) with self.assertRaises(OSError) as cm: setxattr(fn, s("user.test2"), b"bye", os.XATTR_REPLACE, **kwargs) self.assertEqual(cm.exception.errno, errno.ENODATA) setxattr(fn, s("user.test2"), b"foo", os.XATTR_CREATE, **kwargs) xattr.add("user.test2") self.assertEqual(set(listxattr(fn)), xattr) removexattr(fn, s("user.test"), **kwargs) with self.assertRaises(OSError) as cm: getxattr(fn, s("user.test"), **kwargs) self.assertEqual(cm.exception.errno, errno.ENODATA) xattr.remove("user.test") self.assertEqual(set(listxattr(fn)), xattr) self.assertEqual(getxattr(fn, s("user.test2"), **kwargs), b"foo") setxattr(fn, s("user.test"), b"a"*1024, **kwargs) self.assertEqual(getxattr(fn, s("user.test"), **kwargs), b"a"*1024) removexattr(fn, s("user.test"), **kwargs) many = sorted("user.test{}".format(i) for i in range(100)) for thing in many: setxattr(fn, thing, b"x", **kwargs) self.assertEqual(set(listxattr(fn)), set(init_xattr) | set(many))
Example #19
Source File: generic_filters.py From uniconvertor with GNU Affero General Public License v3.0 | 5 votes |
def load(self, presenter, path=None, fileptr=None): self.presenter = presenter self.model = presenter.model self.config = self.presenter.config if path: self.filepath = path self.file_size = os.path.getsize(get_sys_path(path)) self.fileptr = get_fileptr(path) elif fileptr: self.fileptr = fileptr self.fileptr.seek(-1, 1) self.file_size = self.fileptr.tell() self.fileptr.seek(0) else: msg = _('There is no file for reading') raise IOError(errno.ENODATA, msg, '') try: self.init_load() except Exception: LOG.error('Error loading file content') raise self.fileptr.close() self.position = 0 return self.model
Example #20
Source File: migrate.py From ccs-calendarserver with Apache License 2.0 | 4 votes |
def fileStoreFromPath(cls, path): """ @param path: a path pointing at the document root, where the file-based data-store is located. @type path: L{CachingFilePath} """ # Legacy: old file store only ever used these two top-level paths for homeType in ("calendars", "addressbooks"): if path.child(homeType).exists(): if platform.isMacOSX(): appropriateStoreClass = XattrPropertyStore else: attrs = xattr.xattr(path.path) try: attrs.get('user.should-not-be-set') except IOError, ioe: if ioe.errno == errno.ENODATA: # xattrs are supported and enabled on the filesystem # where the calendar data lives. this takes some # doing (you have to edit fstab), so this means # we're trying to migrate some 2.x data from a # previous linux installation. appropriateStoreClass = XattrPropertyStore elif ioe.errno == errno.EOPNOTSUPP: # The operation wasn't supported. This is what will # usually happen on a naively configured filesystem, # so this means we're most likely trying to migrate # some data from an untarred archive created on an # OS X installation using xattrs. appropriateStoreClass = AppleDoubleStore else: # No need to check for ENOENT and the like; we just # checked above to make sure the parent exists. # Other errors are not anticipated here, so fail # fast. raise appropriateStoreClass = AppleDoubleStore from txdav.common.datastore.file import CommonDataStore as FileStore return FileStore( path, None, None, True, True, propertyStoreClass=appropriateStoreClass)
Example #21
Source File: treesum.py From osbuild with Apache License 2.0 | 4 votes |
def treesum(m, dir_fd): """Compute a content hash of a filesystem tree Parameters ---------- m : hash object the hash object to append the treesum to dir_fd : int directory file descriptor number to operate on The hash is stable between runs, and guarantees that two filesystem trees with the same hash, are functionally equivalent from the OS point of view. The file, symlink and directory names and contents are recursively hashed, together with security-relevant metadata.""" with os.scandir(f"/proc/self/fd/{dir_fd}") as it: for dirent in sorted(it, key=(lambda d: d.name)): stat_result = dirent.stat(follow_symlinks=False) metadata = {} metadata["name"] = os.fsdecode(dirent.name) metadata["mode"] = stat_result.st_mode metadata["uid"] = stat_result.st_uid metadata["gid"] = stat_result.st_gid # include the size of symlink target/file-contents so we don't have to delimit it metadata["size"] = stat_result.st_size # getxattr cannot operate on a dir_fd, so do a trick and rely on the entries in /proc stable_file_path = os.path.join(f"/proc/self/fd/{dir_fd}", dirent.name) try: selinux_label = os.getxattr(stable_file_path, b"security.selinux", follow_symlinks=False) except OSError as e: # SELinux support is optional if e.errno != errno.ENODATA: raise else: metadata["selinux"] = os.fsdecode(selinux_label) # hash the JSON representation of the metadata to stay unique/stable/well-defined m.update(json.dumps(metadata, sort_keys=True).encode()) if dirent.is_symlink(): m.update(os.fsdecode(os.readlink(dirent.name, dir_fd=dir_fd)).encode()) else: fd = os.open(dirent.name, flags=os.O_RDONLY, dir_fd=dir_fd) try: if dirent.is_dir(follow_symlinks=False): treesum(m, fd) elif dirent.is_file(follow_symlinks=False): # hash a page at a time (using f with fd as default is a hack to please pylint) for byte_block in iter(lambda f=fd: os.read(f, 4096), b""): m.update(byte_block) else: raise ValueError("Found unexpected filetype on OS image") finally: os.close(fd)