def getDiskInfo(self, path):
def isMountPoint():
try:
fd = open('/proc/mounts', 'r')
for line in fd:
l = line.split()
if len(l) > 1 and l[1] == path:
return True
fd.close()
except:
return None
return False
result = [0,0,0,0] # (size, used, avail, use%)
if isMountPoint():
try:
st = statvfs(path)
except:
st = None
if not st is None and not 0 in (st.f_bsize, st.f_blocks):
result[0] = st.f_bsize * st.f_blocks # size
result[2] = st.f_bsize * st.f_bavail # avail
result[1] = result[0] - result[2] # used
result[3] = result[1] * 100 / result[0] # use%
return result
评论列表
文章目录