本文整理汇总了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
#=========================================================================
示例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
示例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())
示例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)
示例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
示例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")
示例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)