From c90fe0705599fe95cd5ac5a6460d2337dab55959 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 18 Nov 2021 15:21:57 +0000 Subject: Error handling when PARTUUID is missing during __repr__ --- archinstall/lib/disk/partition.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'archinstall/lib/disk') diff --git a/archinstall/lib/disk/partition.py b/archinstall/lib/disk/partition.py index 2469a390..39d67873 100644 --- a/archinstall/lib/disk/partition.py +++ b/archinstall/lib/disk/partition.py @@ -64,10 +64,14 @@ class Partition: elif self.target_mountpoint: mount_repr = f", rel_mountpoint={self.target_mountpoint}" - if self._encrypted: - return f'Partition(path={self.path}, size={self.size}, PARTUUID={self.uuid}, parent={self.real_device}, fs={self.filesystem}{mount_repr})' - else: - return f'Partition(path={self.path}, size={self.size}, PARTUUID={self.uuid}, fs={self.filesystem}{mount_repr})' + try: + if self._encrypted: + return f'Partition(path={self.path}, size={self.size}, PARTUUID={self.uuid}, parent={self.real_device}, fs={self.filesystem}{mount_repr})' + else: + 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): return { -- cgit v1.2.3-54-g00ecf