Fixed a logic test for empty lsblk info

This commit is contained in:
Anton Hvornum 2023-02-23 08:15:24 +01:00
parent 7a9c58141d
commit d23c4acb03
No known key found for this signature in database
GPG Key ID: F1234C5BA67C59DF
2 changed files with 4 additions and 2 deletions

View File

@ -423,7 +423,6 @@ def get_partitions_in_use(mountpoint :str) -> Dict[str, Any]:
return {}
output = json.loads(output)
# print(output)
mounts = {}

View File

@ -223,9 +223,12 @@ class Partition:
lsblk_info = self._call_lsblk()
sfdisk_info = self._call_sfdisk()
if not (device := lsblk_info.get('blockdevices', [None])[0]):
if not (device := lsblk_info.get('blockdevices', [])):
raise DiskError(f'Failed to retrieve information for "{self.device_path}" with lsblk')
# Grab the first (and only) block device in the list as we're targeting a specific partition
device = device[0]
mountpoints = [Path(mountpoint) for mountpoint in device['mountpoints'] if mountpoint]
bootable = sfdisk_info.get('bootable', False) or sfdisk_info.get('type', '') == 'C12A7328-F81F-11D2-BA4B-00A0C93EC93B'