Reworked the last uuid fix, and introduced _safe_uuid which does the same thing but handles the DisKerror. This way we can use it in more places.
This commit is contained in:
parent
c90fe07055
commit
61bc59f5bf
|
|
@ -64,19 +64,15 @@ class Partition:
|
||||||
elif self.target_mountpoint:
|
elif self.target_mountpoint:
|
||||||
mount_repr = f", rel_mountpoint={self.target_mountpoint}"
|
mount_repr = f", rel_mountpoint={self.target_mountpoint}"
|
||||||
|
|
||||||
try:
|
if self._encrypted:
|
||||||
if self._encrypted:
|
return f'Partition(path={self.path}, size={self.size}, PARTUUID={self._safe_uuid}, parent={self.real_device}, fs={self.filesystem}{mount_repr})'
|
||||||
return f'Partition(path={self.path}, size={self.size}, PARTUUID={self.uuid}, parent={self.real_device}, fs={self.filesystem}{mount_repr})'
|
else:
|
||||||
else:
|
return f'Partition(path={self.path}, size={self.size}, PARTUUID={self._safe_uuid}, fs={self.filesystem}{mount_repr})'
|
||||||
return f'Partition(path={self.path}, size={self.size}, PARTUUID={self.uuid}, fs={self.filesystem}{mount_repr})'
|
|
||||||
except DiskError:
|
|
||||||
# DiskErrors occur when we cannot retrieve the UUID of the partition, usually due to encryption or a slow disk.
|
|
||||||
return f'Partition(path={self.path}, size={self.size}, PARTUUID=None, fs={self.filesystem}{mount_repr})'
|
|
||||||
|
|
||||||
def __dump__(self):
|
def __dump__(self):
|
||||||
return {
|
return {
|
||||||
'type' : 'primary',
|
'type' : 'primary',
|
||||||
'PARTUUID' : self.uuid,
|
'PARTUUID' : self._safe_uuid,
|
||||||
'wipe' : self.allow_formatting,
|
'wipe' : self.allow_formatting,
|
||||||
'boot' : self.boot,
|
'boot' : self.boot,
|
||||||
'ESP' : self.boot,
|
'ESP' : self.boot,
|
||||||
|
|
@ -164,6 +160,13 @@ class Partition:
|
||||||
|
|
||||||
raise DiskError(f"Could not get PARTUUID for {self.path} using 'lsblk -J -o+PARTUUID {self.path}'")
|
raise DiskError(f"Could not get PARTUUID for {self.path} using 'lsblk -J -o+PARTUUID {self.path}'")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _safe_uuid(self):
|
||||||
|
try:
|
||||||
|
return self.uuid
|
||||||
|
except DiskError:
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def encrypted(self):
|
def encrypted(self):
|
||||||
return self._encrypted
|
return self._encrypted
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue