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
评论列表
文章目录