当前位置: 首页>>代码示例>>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;未经允许,请勿转载。