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


Python stat.ST_DEV屬性代碼示例

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


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

示例1: emit

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_DEV [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_DEV [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_DEV [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: _statstream

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_DEV [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

示例5: emit

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_DEV [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

示例6: __init__

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_DEV [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

示例7: emit

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_DEV [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

示例8: is_same_hard_link

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_DEV [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

示例9: emit

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_DEV [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

示例10: reopenIfNeeded

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_DEV [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

示例11: acquire

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_DEV [as 別名]
def acquire(self):
        """Returns True if file has been changed, False otherwise"""
        ret = False
        while True:
            if not self.file:
                self.file = open(self.path, 'a')
                self.fstatd = os.fstat(self.file.fileno())
                ret = True
            try:
                fcntl.flock(self.file, fcntl.LOCK_EX)
            except Exception:
                try:
                    self.file.close()
                except Exception:
                    pass
                self.file = None
                raise
            try:
                statd = os.stat(self.path)
            except FileNotFoundError:
                try:
                    self.file.close()
                except Exception:
                    pass
                self.file = None
                continue
            except Exception:
                try:
                    self.file.close()
                except Exception:
                    pass
                self.file = None
                raise
            if self.fstatd[stat.ST_DEV] == statd[stat.ST_DEV] and \
               self.fstatd[stat.ST_INO] == statd[stat.ST_INO]:
                return ret
            self.file.close()
            self.file = None 
開發者ID:quantopian,項目名稱:PenguinDome,代碼行數:40,代碼來源:penguindome.py


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