Convert lsblk mountpoint str to Path object (#2676)

This commit is contained in:
codefiles 2024-09-08 17:28:09 -04:00 committed by GitHub
parent 7235e21c3a
commit a45bd248c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -1345,7 +1345,7 @@ class LsblkInfo:
'fsavail': self.fsavail,
'fsuse_percentage': self.fsuse_percentage,
'type': self.type,
'mountpoint': self.mountpoint,
'mountpoint': str(self.mountpoint) if self.mountpoint else None,
'mountpoints': [str(m) for m in self.mountpoints],
'fsroots': [str(r) for r in self.fsroots],
'children': [c.json() for c in self.children]
@ -1393,6 +1393,8 @@ class LsblkInfo:
lsblk_info.children = [LsblkInfo.from_json(child) for child in blockdevice.get('children', [])]
lsblk_info.mountpoint = Path(lsblk_info.mountpoint) if lsblk_info.mountpoint else None
# sometimes lsblk returns 'mountpoints': [null]
lsblk_info.mountpoints = [Path(mnt) for mnt in lsblk_info.mountpoints if mnt]