def get_path_usage(path):
space_st = os.statvfs(path)
# f_bavail: without blocks reserved for super users
# f_bfree: with blocks reserved for super users
avail = space_st.f_frsize * space_st.f_bavail
capa = space_st.f_frsize * space_st.f_blocks
used = capa - avail
return {
'total': capa,
'used': used,
'available': avail,
'percent': float(used) / capa,
}
评论列表
文章目录