Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-11-18 15:34:26 +0000
committerGitHub <noreply@github.com>2021-11-18 15:34:26 +0000
commit69810abb16478889118bdba1fed5c572acf33b5a (patch)
tree7681da326a750d1f22e5802480781e0edd154e5c
parent37c84e1781a6813804f5bb8c65709e91b331b334 (diff)
parent96332670c3f58770c7529aa0ef4fc96760172199 (diff)
Merged PR #735 - Removes delays from Partition()._safe_uuid
Adds Partition()._safe_uuid as a addon to Partition().uuid without exceptions
-rw-r--r--archinstall/lib/disk/partition.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/archinstall/lib/disk/partition.py b/archinstall/lib/disk/partition.py
index 39d67873..f8378d47 100644
--- a/archinstall/lib/disk/partition.py
+++ b/archinstall/lib/disk/partition.py
@@ -64,19 +64,15 @@ class Partition:
elif self.target_mountpoint:
mount_repr = f", rel_mountpoint={self.target_mountpoint}"
- 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})'
+ 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})'
+ else:
+ return f'Partition(path={self.path}, size={self.size}, PARTUUID={self._safe_uuid}, fs={self.filesystem}{mount_repr})'
def __dump__(self):
return {
'type' : 'primary',
- 'PARTUUID' : self.uuid,
+ 'PARTUUID' : self._safe_uuid,
'wipe' : self.allow_formatting,
'boot' : self.boot,
'ESP' : self.boot,
@@ -165,6 +161,21 @@ class Partition:
raise DiskError(f"Could not get PARTUUID for {self.path} using 'lsblk -J -o+PARTUUID {self.path}'")
@property
+ def _safe_uuid(self) -> Optional[str]:
+ """
+ A near copy of self.uuid but without any delays.
+ This function should only be used where uuid is not crucial.
+ For instance when you want to get a __repr__ of the class.
+ """
+ self.partprobe()
+
+ partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
+ if partuuid_struct.exit_code == 0:
+ if partition_information := next(iter(json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']), None):
+ if (partuuid := partition_information.get('partuuid', None)):
+ return partuuid
+
+ @property
def encrypted(self):
return self._encrypted