Python posix.stat_result() Examples
The following are 13
code examples of posix.stat_result().
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
posix
, or try the search function
.
Example #1
Source File: test_posixpath.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_ismount_different_device(self): # Simulate the path being on a different device from its parent by # mocking out st_dev. save_lstat = os.lstat def fake_lstat(path): st_ino = 0 st_dev = 0 if path == ABSTFN: st_dev = 1 st_ino = 1 return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0)) try: os.lstat = fake_lstat self.assertIs(posixpath.ismount(ABSTFN), True) finally: os.lstat = save_lstat
Example #2
Source File: test_posixpath.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_ismount_directory_not_readable(self): # issue #2466: Simulate ismount run on a directory that is not # readable, which used to return False. save_lstat = os.lstat def fake_lstat(path): st_ino = 0 st_dev = 0 if path.startswith(ABSTFN) and path != ABSTFN: # ismount tries to read something inside the ABSTFN directory; # simulate this being forbidden (no read permission). raise OSError("Fake [Errno 13] Permission denied") if path == ABSTFN: st_dev = 1 st_ino = 1 return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0)) try: os.lstat = fake_lstat self.assertIs(posixpath.ismount(ABSTFN), True) finally: os.lstat = save_lstat
Example #3
Source File: test_posixpath.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_ismount_different_device(self): # Simulate the path being on a different device from its parent by # mocking out st_dev. save_lstat = os.lstat def fake_lstat(path): st_ino = 0 st_dev = 0 if path == ABSTFN: st_dev = 1 st_ino = 1 return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0)) try: os.lstat = fake_lstat self.assertIs(posixpath.ismount(ABSTFN), True) finally: os.lstat = save_lstat
Example #4
Source File: test_posixpath.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_ismount_different_device(self): # Simulate the path being on a different device from its parent by # mocking out st_dev. save_lstat = os.lstat def fake_lstat(path): st_ino = 0 st_dev = 0 if path == ABSTFN: st_dev = 1 st_ino = 1 return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0)) try: os.lstat = fake_lstat self.assertIs(posixpath.ismount(ABSTFN), True) finally: os.lstat = save_lstat
Example #5
Source File: test_posixpath.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_ismount_different_device(self): # Simulate the path being on a different device from its parent by # mocking out st_dev. save_lstat = os.lstat def fake_lstat(path): st_ino = 0 st_dev = 0 if path == ABSTFN: st_dev = 1 st_ino = 1 return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0)) try: os.lstat = fake_lstat self.assertIs(posixpath.ismount(ABSTFN), True) finally: os.lstat = save_lstat
Example #6
Source File: test_posixpath.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_ismount_directory_not_readable(self): # issue #2466: Simulate ismount run on a directory that is not # readable, which used to return False. save_lstat = os.lstat def fake_lstat(path): st_ino = 0 st_dev = 0 if path.startswith(ABSTFN) and path != ABSTFN: # ismount tries to read something inside the ABSTFN directory; # simulate this being forbidden (no read permission). raise OSError("Fake [Errno 13] Permission denied") if path == ABSTFN: st_dev = 1 st_ino = 1 return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0)) try: os.lstat = fake_lstat self.assertIs(posixpath.ismount(ABSTFN), True) finally: os.lstat = save_lstat
Example #7
Source File: test_posixpath.py From android_universal with MIT License | 6 votes |
def test_ismount_different_device(self): # Simulate the path being on a different device from its parent by # mocking out st_dev. save_lstat = os.lstat def fake_lstat(path): st_ino = 0 st_dev = 0 if path == ABSTFN: st_dev = 1 st_ino = 1 return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0)) try: os.lstat = fake_lstat self.assertIs(posixpath.ismount(ABSTFN), True) finally: os.lstat = save_lstat
Example #8
Source File: test_posixpath.py From android_universal with MIT License | 6 votes |
def test_ismount_directory_not_readable(self): # issue #2466: Simulate ismount run on a directory that is not # readable, which used to return False. save_lstat = os.lstat def fake_lstat(path): st_ino = 0 st_dev = 0 if path.startswith(ABSTFN) and path != ABSTFN: # ismount tries to read something inside the ABSTFN directory; # simulate this being forbidden (no read permission). raise OSError("Fake [Errno 13] Permission denied") if path == ABSTFN: st_dev = 1 st_ino = 1 return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0)) try: os.lstat = fake_lstat self.assertIs(posixpath.ismount(ABSTFN), True) finally: os.lstat = save_lstat
Example #9
Source File: filestest.py From conary with Apache License 2.0 | 5 votes |
def testUnknownUser(self): # CNY-1071 # Tests that FileFromFilesystem packs '+UID' as the owner (and '+GID' # as the group) if the owner/group don't exist. fobj = tempfile.NamedTemporaryFile() fobj.write("test\n") fobj.flush() uid, gid = self.findUnknownIds() import posix origLstat = os.lstat def myLstat(path): s = origLstat(path) if path == fobj.name: # Convert the stat info to a tuple s = tuple(s) # Replace st_uid and st_gid s = s[:4] + (uid, gid) + s[6:] # Convert to stat_result s = posix.stat_result(s) self.assertEqual(s.st_uid, uid) self.assertEqual(s.st_gid, gid) return s try: os.lstat = myLstat # No failure here f = files.FileFromFilesystem(fobj.name, None) self.assertEqual(f.inode.owner(), "+" + str(uid)) self.assertEqual(f.inode.group(), "+" + str(gid)) finally: os.lstat = origLstat
Example #10
Source File: _exxo_hack.py From exxo with ISC License | 5 votes |
def stat_file(filename): inzip_path, is_dir = _get_inzip_path(filename, OSError) info = exxo_importer.exe_zip.getinfo(inzip_path) stat_result = list(os.stat(sys.executable)) stat_result[6] = info.file_size if is_dir: stat_result[0] &= ~(stat.S_IFREG | stat.S_IFLNK) stat_result[0] |= stat.S_IFDIR return posix.stat_result(stat_result)
Example #11
Source File: s3path.py From s3path with Apache License 2.0 | 5 votes |
def stat(self): """ Returns information about this path (similarly to boto3's ObjectSummary). For compatibility with pathlib, the returned object some similar attributes like os.stat_result. The result is looked up at each call to this method """ self._absolute_path_validation() if not self.key: return None return super().stat()
Example #12
Source File: s3path.py From s3path with Apache License 2.0 | 5 votes |
def __getattr__(self, item): if item in vars(stat_result): raise UnsupportedOperation('{} do not support {} attribute'.format(type(self).__name__, item)) return super().__getattribute__(item)
Example #13
Source File: updatetest.py From conary with Apache License 2.0 | 4 votes |
def testUnknownUser(self): # CNY-1071 repos = self.openRepository() self.addComponent('foo:runtime', '1', '', [('/foo/contents0', 'foo\n')]) self.updatePkg('foo:runtime') uid, gid = self.findUnknownIds() import posix origLstat = os.lstat def myLstat(path): s = origLstat(path) if path == util.joinPaths(self.rootDir, '/foo/contents0'): # Convert the stat info to a tuple s = tuple(s) # Replace st_uid and st_gid s = s[:4] + (uid, gid) + s[6:] # Convert to stat_result s = posix.stat_result(s) self.assertEqual(s.st_uid, uid) self.assertEqual(s.st_gid, gid) return s try: os.lstat = myLstat # No errors here self.erasePkg(self.rootDir, 'foo:runtime', '1') db = database.Database(self.rootDir, self.cfg.dbPath) rbnum = db.rollbackStack.getList()[-1] rb = db.rollbackStack.getRollback(rbnum) # Make changeset absolute cs = rb.getLocalChangeset(0).makeAbsolute(repos) self.logFilter.add() ret, out = self.captureOutput(showchangeset.displayChangeSet, db, cs, None, self.cfg, lsl=True) # Verify there is a warning. self.logFilter.compare( ['warning: No primary troves in changeset, listing all troves'] ) # Make sure we don't display the plus sign self.assertEqual(out[:33], "-rw-r--r-- 1 %-8s %-8s" % (uid, gid)) # No errors here either self.rollback(self.rootDir, 1) finally: os.lstat = origLstat