當前位置: 首頁>>代碼示例>>Python>>正文


Python stat.ST_INO屬性代碼示例

本文整理匯總了Python中stat.ST_INO屬性的典型用法代碼示例。如果您正苦於以下問題:Python stat.ST_INO屬性的具體用法?Python stat.ST_INO怎麽用?Python stat.ST_INO使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在stat的用法示例。


在下文中一共展示了stat.ST_INO屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: emit

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def emit(self, record):
        """
        Emit a record.

        First check if the underlying file has changed, and if it
        has, close the old stream and reopen the file to get the
        current stream.
        """
        if not os.path.exists(self.baseFilename):
            stat = None
            changed = 1
        else:
            stat = os.stat(self.baseFilename)
            changed = (stat[ST_DEV] != self.dev) or (stat[ST_INO] != self.ino)
        if changed and self.stream is not None:
            self.stream.flush()
            self.stream.close()
            self.stream = self._open()
            if stat is None:
                stat = os.stat(self.baseFilename)
            self.dev, self.ino = stat[ST_DEV], stat[ST_INO]
        logging.FileHandler.emit(self, record) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:24,代碼來源:handlers.py

示例2: test_pex_builder_copy_or_link

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def test_pex_builder_copy_or_link():
  with nested(temporary_dir(), temporary_dir(), temporary_dir()) as (td1, td2, td3):
    src = os.path.join(td1, 'exe.py')
    with open(src, 'w') as fp:
      fp.write(exe_main)

    def build_and_check(path, copy):
      pb = PEXBuilder(path=path, copy=copy)
      pb.add_source(src, 'exe.py')

      path_clone = os.path.join(path, '__clone')
      pb.clone(into=path_clone)

      for root in path, path_clone:
        s1 = os.stat(src)
        s2 = os.stat(os.path.join(root, 'exe.py'))
        is_link = (s1[stat.ST_INO], s1[stat.ST_DEV]) == (s2[stat.ST_INO], s2[stat.ST_DEV])
        if copy:
          assert not is_link
        else:
          assert is_link

    build_and_check(td2, False)
    build_and_check(td3, True) 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:26,代碼來源:test_pex_builder.py

示例3: reopen_file

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def reopen_file(self):
        try:
            # stat the file by path, checking for existence
            sres = os.stat(self.baseFilename)
        except OSError as err:
            if err.errno == errno.ENOENT:
                sres = None
            else:
                raise
        # compare file system stat with that of our stream file handle
        if (not sres or
                sres[stat.ST_DEV] != self.dev or
                sres[stat.ST_INO] != self.ino):
            if self.stream is not None:
                # we have an open file handle, clean it up
                self.stream.flush()
                self.stream.close()
                self.stream = None
                # open a new file handle and get new stat info from that fd
                self.stream = self._open()
                self._statstream() 
開發者ID:openstack,項目名稱:oslo.log,代碼行數:23,代碼來源:watchers.py

示例4: testLinkGroups

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def testLinkGroups(self):
        srcVersion  = self.addCompAndPackage('foo:runtime', '1.0-1-1',
                      fileContents = [
                           ('/bin/onefile', rephelp.RegularFile(
                                            linkGroup = '\1'*16,
                                            contents = 'contents',
                                            perms = 0700) ),
                           ('/bin/anotherfile', rephelp.RegularFile(
                                            linkGroup = '\1'*16,
                                            contents = 'contents',
                                            perms = 0700) ),
                                            ] )

        pkgTrv, runtimeTrv = self.buildDerivation('foo', srcVersion,
               "r.Link('yetanother', '/bin/onefile')",
               returnTrove = [ 'foo', ':runtime' ])
        self.updatePkg('%s=%s' % (pkgTrv.getName(), pkgTrv.getVersion()))
        inode1 = os.stat(self.rootDir+'/bin/onefile')[stat.ST_INO]
        inode2 = os.stat(self.rootDir+'/bin/anotherfile')[stat.ST_INO]
        inode3 = os.stat(self.rootDir+'/bin/yetanother')[stat.ST_INO]
        self.assertEqual(inode1, inode2)
        self.assertEqual(inode1, inode3) 
開發者ID:sassoftware,項目名稱:conary,代碼行數:24,代碼來源:derivedtest.py

示例5: testLinkTestGood

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def testLinkTestGood(self):
        recipestr2 = """
class TestLink(PackageRecipe):
    name = 'test'
    version = '0'
    clearBuildReqs()
    
    def setup(r):
        r.macros.foo = '/foo'
        r.macros.bar = 'bar'
        r.Create('%(foo)s',
            contents='ABCDEFGABCDEFGABCDEFGABCDEFG%(destdir)s/')
        r.Link('%(bar)s', 'blah', '%(foo)s')
"""
        self.reset()
        (built, d) = self.buildRecipe(recipestr2, "TestLink")
        for p in built:
            self.updatePkg(self.workDir, p[0], p[1])
        a = os.lstat(util.joinPaths(self.workDir, 'foo'))
        b = os.lstat(util.joinPaths(self.workDir, 'bar'))
        c = os.lstat(util.joinPaths(self.workDir, 'blah'))
        assert(a[stat.ST_INO] == b[stat.ST_INO])
        assert(b[stat.ST_INO] == c[stat.ST_INO]) 
開發者ID:sassoftware,項目名稱:conary,代碼行數:25,代碼來源:buildtest.py

示例6: _statstream

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def _statstream(self):
        if self.stream:
            sres = os.fstat(self.stream.fileno())
            self.dev, self.ino = sres[ST_DEV], sres[ST_INO] 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:6,代碼來源:handlers.py

示例7: emit

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def emit(self, record):
        """
        Emit a record.

        First check if the underlying file has changed, and if it
        has, close the old stream and reopen the file to get the
        current stream.
        """
        # Reduce the chance of race conditions by stat'ing by path only
        # once and then fstat'ing our new fd if we opened a new log stream.
        # See issue #14632: Thanks to John Mulligan for the problem report
        # and patch.
        try:
            # stat the file by path, checking for existence
            sres = os.stat(self.baseFilename)
        except OSError as err:
            if err.errno == errno.ENOENT:
                sres = None
            else:
                raise
        # compare file system stat with that of our stream file handle
        if not sres or sres[ST_DEV] != self.dev or sres[ST_INO] != self.ino:
            if self.stream is not None:
                # we have an open file handle, clean it up
                self.stream.flush()
                self.stream.close()
                # open a new file handle and get new stat info from that fd
                self.stream = self._open()
                self._statstream()
        logging.FileHandler.emit(self, record) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:32,代碼來源:handlers.py

示例8: __init__

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def __init__(self, filename, mode='a', encoding=None, delay=0):
        logging.FileHandler.__init__(self, filename, mode, encoding, delay)
        if not os.path.exists(self.baseFilename):
            self.dev, self.ino = -1, -1
        else:
            stat = os.stat(self.baseFilename)
            self.dev, self.ino = stat[ST_DEV], stat[ST_INO] 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:9,代碼來源:handlers.py

示例9: emit

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def emit(self, record):
        """
        Emit a record.

        First check if the underlying file has changed, and if it
        has, close the old stream and reopen the file to get the
        current stream.
        """
        # Reduce the chance of race conditions by stat'ing by path only
        # once and then fstat'ing our new fd if we opened a new log stream.
        # See issue #14632: Thanks to John Mulligan for the problem report
        # and patch.
        try:
            # stat the file by path, checking for existence
            sres = os.stat(self.baseFilename)
        except OSError as err:
            if err.errno == errno.ENOENT:
                sres = None
            else:
                raise
        # compare file system stat with that of our stream file handle
        if not sres or sres[ST_DEV] != self.dev or sres[ST_INO] != self.ino:
            if self.stream is not None:
                # we have an open file handle, clean it up
                self.stream.flush()
                self.stream.close()
                self.stream = None  # See Issue #21742: _open () might fail.
                # open a new file handle and get new stat info from that fd
                self.stream = self._open()
                self._statstream()
        logging.FileHandler.emit(self, record) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:33,代碼來源:handlers.py

示例10: write_last_stat

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def write_last_stat(self, f, offset):

        st = os.fstat(f.fileno())

        ino = st[stat.ST_INO]

        last = {
            "inode": ino,
            "offset": offset,
        }

        fsutil.write_file(self.stat_path(), utfjson.dump(last), fsync=False)

        logger.info('position written fn=%s inode=%d offset=%d' % (
            self.fn, ino, offset)) 
開發者ID:bsc-s2,項目名稱:pykit,代碼行數:17,代碼來源:cat.py

示例11: get_last_offset

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def get_last_offset(self, f, default_seek):
        st = os.fstat(f.fileno())
        ino = st[stat.ST_INO]
        size = st[stat.ST_SIZE]

        max_residual = None

        if default_seek is None or default_seek == SEEK_START:
            default_offset = 0

        elif default_seek == SEEK_END:
            default_offset = size

        elif default_seek < 0:
            max_residual = 0 - default_seek
            default_offset = max(size - max_residual, 0)

        else:
            default_offset = default_seek

        stat_file = self.stat_path()

        if not os.path.isfile(stat_file):
            return default_offset

        try:
            last = self.read_last_stat()
        except (IOError, ValueError):
            # damaged stat file
            return default_offset

        if max_residual is not None:
            if size - last['offset'] > max_residual:
                last['offset'] = size - max_residual

        if last['inode'] != ino or last['offset'] > size:
            return default_offset

        return last['offset'] 
開發者ID:bsc-s2,項目名稱:pykit,代碼行數:41,代碼來源:cat.py

示例12: is_same_hard_link

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def is_same_hard_link(filename:str, other:str):
    s1 = os.stat(filename)
    s2 = os.stat(other)
    return (s1[stat.ST_INO], s1[stat.ST_DEV]) == \
        (s2[stat.ST_INO], s2[stat.ST_DEV])

# MetaDB tables 
開發者ID:rstojnic,項目名稱:lazydata,代碼行數:9,代碼來源:local.py

示例13: test_dataset_add_with_copy

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def test_dataset_add_with_copy(tmpdir, runner, project, client):
    """Test adding data to dataset with copy."""
    import os
    import stat

    # create a dataset
    result = runner.invoke(cli, ['dataset', 'create', 'my-dataset'])
    assert 0 == result.exit_code
    assert 'OK' in result.output

    paths = []
    original_inodes = []
    for i in range(3):
        new_file = tmpdir.join('file_{0}'.format(i))
        new_file.write(str(i))
        original_inodes.append(os.lstat(str(new_file))[stat.ST_INO])
        paths.append(str(new_file))

    # add data
    result = runner.invoke(
        cli,
        ['dataset', 'add', 'my-dataset'] + paths,
    )
    assert 0 == result.exit_code

    received_inodes = []
    with client.with_dataset('my-dataset') as dataset:
        assert dataset.name == 'my-dataset'

        for file_ in dataset.files:
            path_ = (client.path / file_.path).resolve()
            received_inodes.append(os.lstat(str(path_))[stat.ST_INO])

    # check that original inodes are within created ones
    for inode in received_inodes:
        assert inode not in original_inodes 
開發者ID:SwissDataScienceCenter,項目名稱:renku-python,代碼行數:38,代碼來源:test_datasets.py

示例14: emit

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def emit(self, record):
        """
        Emit a record.

        First check if the underlying file has changed, and if it
        has, close the old stream and reopen the file to get the
        current stream.
        """
        # Reduce the chance of race conditions by stat'ing by path only
        # once and then fstat'ing our new fd if we opened a new log stream.
        # See issue #14632: Thanks to John Mulligan for the problem report
        # and patch.
        try:
            # stat the file by path, checking for existence
            sres = os.stat(self.baseFilename)
        except FileNotFoundError:
            sres = None
        # compare file system stat with that of our stream file handle
        if not sres or sres[ST_DEV] != self.dev or sres[ST_INO] != self.ino:
            if self.stream is not None:
                # we have an open file handle, clean it up
                self.stream.flush()
                self.stream.close()
                self.stream = None  # See Issue #21742: _open () might fail.
                # open a new file handle and get new stat info from that fd
                self.stream = self._open()
                self._statstream()
        logging.FileHandler.emit(self, record) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:30,代碼來源:handlers.py

示例15: reopenIfNeeded

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_INO [as 別名]
def reopenIfNeeded(self):
        """
        Reopen log file if needed.

        Checks if the underlying file has changed, and if it
        has, close the old stream and reopen the file to get the
        current stream.
        """
        # Reduce the chance of race conditions by stat'ing by path only
        # once and then fstat'ing our new fd if we opened a new log stream.
        # See issue #14632: Thanks to John Mulligan for the problem report
        # and patch.
        try:
            # stat the file by path, checking for existence
            sres = os.stat(self.baseFilename)
        except FileNotFoundError:
            sres = None
        # compare file system stat with that of our stream file handle
        if not sres or sres[ST_DEV] != self.dev or sres[ST_INO] != self.ino:
            if self.stream is not None:
                # we have an open file handle, clean it up
                self.stream.flush()
                self.stream.close()
                self.stream = None  # See Issue #21742: _open () might fail.
                # open a new file handle and get new stat info from that fd
                self.stream = self._open()
                self._statstream() 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:29,代碼來源:handlers.py


注:本文中的stat.ST_INO屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。