SpaceInfo.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:enigma2 作者: OpenLD 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号