Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/disk')
-rw-r--r--archinstall/lib/disk/device_model.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/archinstall/lib/disk/device_model.py b/archinstall/lib/disk/device_model.py
index 987a1e8a..8e26b1d7 100644
--- a/archinstall/lib/disk/device_model.py
+++ b/archinstall/lib/disk/device_model.py
@@ -974,32 +974,33 @@ def _fetch_lsblk_info(dev_path: Optional[Union[Path, str]] = None, retry: int =
if retry == 0:
retry = 1
- result = None
-
- for i in range(retry):
+ for retry_attempt in range(retry):
try:
result = SysCommand(f'lsblk --json -b -o+{lsblk_fields} {dev_path}')
+ break
except SysCallError as error:
# Get the output minus the message/info from lsblk if it returns a non-zero exit code.
if error.worker:
err = error.worker.decode('UTF-8')
log(f'Error calling lsblk: {err}', level=logging.DEBUG)
- time.sleep(1)
else:
raise error
- if result and result.exit_code == 0:
- try:
- if decoded := result.decode('utf-8'):
- block_devices = json.loads(decoded)
- blockdevices = block_devices['blockdevices']
- return [LsblkInfo.from_json(device) for device in blockdevices]
- except json.decoder.JSONDecodeError as err:
- log(f"Could not decode lsblk JSON: {result}", fg="red", level=logging.ERROR)
- raise err
+ if retry_attempt == retry - 1:
+ raise error
- raise DiskError(f'Failed to read disk "{dev_path}" with lsblk')
+ time.sleep(1)
+
+ try:
+ if decoded := result.decode('utf-8'):
+ block_devices = json.loads(decoded)
+ blockdevices = block_devices['blockdevices']
+ return [LsblkInfo.from_json(device) for device in blockdevices]
+ except json.decoder.JSONDecodeError as err:
+ log(f"Could not decode lsblk JSON: {result}", fg="red", level=logging.ERROR)
+ raise err
+ raise DiskError(f'Failed to read disk "{dev_path}" with lsblk')
def get_lsblk_info(dev_path: Union[Path, str]) -> LsblkInfo:
if infos := _fetch_lsblk_info(dev_path):