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


Python os.fstatvfs方法代碼示例

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


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

示例1: _get_io_blocksize_MB_

# 需要導入模塊: import os [as 別名]
# 或者: from os import fstatvfs [as 別名]
def _get_io_blocksize_MB_(pathname):
    """
    Return the I/O blocksize for a given path (used to estimate IOPS)
    """
    if isfile(pathname):
        fname = pathname
        fflag = O_RDONLY
    elif isdir(pathname):
        fname = join(pathname, '.bsize_test_file')
        fflag = O_CREAT
    else:
        return None
    fd = fdopen(fname, fflag)
    bsize = fstatvfs(fd).f_bsize
    fdclose(fd)
    return bsize


#=========================================================================
# create_reshaper factory function
#========================================================================= 
開發者ID:NCAR,項目名稱:PyReshaper,代碼行數:23,代碼來源:reshaper.py

示例2: get_shared_memory_bytes

# 需要導入模塊: import os [as 別名]
# 或者: from os import fstatvfs [as 別名]
def get_shared_memory_bytes():
    """Get the size of the shared memory file system.

    Returns:
        The size of the shared memory file system in bytes.
    """
    # Make sure this is only called on Linux.
    assert sys.platform == "linux" or sys.platform == "linux2"

    shm_fd = os.open("/dev/shm", os.O_RDONLY)
    try:
        shm_fs_stats = os.fstatvfs(shm_fd)
        # The value shm_fs_stats.f_bsize is the block size and the
        # value shm_fs_stats.f_bavail is the number of available
        # blocks.
        shm_avail = shm_fs_stats.f_bsize * shm_fs_stats.f_bavail
    finally:
        os.close(shm_fd)

    return shm_avail 
開發者ID:ray-project,項目名稱:ray,代碼行數:22,代碼來源:utils.py

示例3: fstatvfs

# 需要導入模塊: import os [as 別名]
# 或者: from os import fstatvfs [as 別名]
def fstatvfs(self, handle):
        fo = self._files.get(handle, None)
        if fo:
            return os.fstatvfs(fo.fileno()) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:6,代碼來源:PosixServer.py

示例4: ino_check

# 需要導入模塊: import os [as 別名]
# 或者: from os import fstatvfs [as 別名]
def ino_check(dev, min_ino=MIN_INODES):
    return os.fstatvfs(dev).f_ffree >= int(min_ino) 
開發者ID:ebranca,項目名稱:owasp-pysec,代碼行數:4,代碼來源:fcheck.py

示例5: space_check

# 需要導入模塊: import os [as 別名]
# 或者: from os import fstatvfs [as 別名]
def space_check(dev, size):
    stdev = os.fstatvfs(dev)
    return size < stdev.f_bfree * stdev.f_bsize 
開發者ID:ebranca,項目名稱:owasp-pysec,代碼行數:5,代碼來源:fcheck.py

示例6: copyTo

# 需要導入模塊: import os [as 別名]
# 或者: from os import fstatvfs [as 別名]
def copyTo(self, destination):
        # XXX TODO: *thorough* audit and documentation of the exact desired
        # semantics of this code.  Right now the behavior of existent
        # destination symlinks is convenient, and quite possibly correct, but
        # its security properties need to be explained.
        if self.isdir():
            if not destination.exists():
                destination.createDirectory()
            for child in self.children():
                destChild = destination.child(child.basename())
                child.copyTo(destChild)
        elif self.isfile():
            writefile = destination.open('w')
            readfile = self.open()
            while 1:
                # XXX TODO: optionally use os.open, os.read and O_DIRECT and
                # use os.fstatvfs to determine chunk sizes and make
                # *****sure**** copy is page-atomic; the following is good
                # enough for 99.9% of everybody and won't take a week to audit
                # though.
                chunk = readfile.read(self._chunkSize)
                writefile.write(chunk)
                if len(chunk) < self._chunkSize:
                    break
            writefile.close()
            readfile.close()
        else:
            # If you see the following message because you want to copy
            # symlinks, fifos, block devices, character devices, or unix
            # sockets, please feel free to add support to do sensible things in
            # reaction to those types!
            raise NotImplementedError(
                "Only copying of files and directories supported") 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:35,代碼來源:filepath.py

示例7: free_space

# 需要導入模塊: import os [as 別名]
# 或者: from os import fstatvfs [as 別名]
def free_space(f):
    """ return ( Bytes Free, Nodes free ) for the filesystem containing the provided file
        ex: free_space( open( '/tmp/nonexistant', 'w' ) ) -> ( bytes=123456789 , nodes=1234 )
    """
    vfs = os.fstatvfs(f.fileno())
    return FreeSpace(bytes = vfs.f_bavail * vfs.f_frsize, nodes = vfs.f_favail) 
開發者ID:rocknsm,項目名稱:docket,代碼行數:8,代碼來源:utils.py


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