btrfsdriver.py 文件源码

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

项目:cobalt 作者: PressLabs 项目源码 文件源码
def get_all(self):
        ids = []
        try:
            subvolumes = self._btrfs('subvolume', 'list', '-o', self._base_path)
            subvolumes = subvolumes.strip()

            for line in subvolumes.splitlines():
                path = line.strip().split()[-1]

                try:
                    id = None

                    # Seems like output may vary, the path can be absolute or relative
                    # so a check is needed
                    if '/' not in path:
                        id = path
                    elif self._base_path in path:
                        id = path[path.index('{}/'.format(self._base_path)):].replace('{}/'.format(self._base_path), '')

                    if id:
                        ids.append(id)
                except ValueError:
                    pass

        except sh.ErrorReturnCode_1 as e:
            print(self._err('get_all', e.stderr, e.full_cmd))
            return []

        return ids
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号