index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Daemon Coder <11915375+codefiles@users.noreply.github.com> | 2023-05-04 03:45:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 09:45:43 +0200 |
commit | adceed22ad3d8b6aa1e6d1aee56ae0c9a0a751aa (patch) | |
tree | b30932e6c478c628fd32d3f79e7ecaabf38ceeb5 | |
parent | 9e5d45c5d8762bb9125a153c528957cef9bc7d24 (diff) |
-rw-r--r-- | archinstall/lib/disk/device_model.py | 29 |
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): |