Use run for lsblk command (#4654)

This commit is contained in:
codefiles 2026-07-22 04:25:55 -04:00 committed by GitHub
parent 6dff8525fd
commit a633fc5d27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 7 deletions

View File

@ -1,8 +1,9 @@
from pathlib import Path
from subprocess import CalledProcessError
from pydantic import BaseModel
from archinstall.lib.command import SysCommand
from archinstall.lib.command import SysCommand, run
from archinstall.lib.exceptions import DiskError, SysCallError
from archinstall.lib.log import debug, info, warn
from archinstall.lib.models.device import LsblkInfo
@ -29,19 +30,18 @@ def _fetch_lsblk_info(
cmd.append(str(dev_path))
try:
worker = SysCommand(cmd)
except SysCallError as err:
result = run(cmd)
except CalledProcessError as err:
# Get the output minus the message/info from lsblk if it returns a non-zero exit code.
if err.worker_log:
debug(f'Error calling lsblk: {err.worker_log.decode()}')
if stdout := err.stdout:
debug(f'Error calling lsblk: {stdout.decode().rstrip()}')
if dev_path:
raise DiskError(f'Failed to read disk "{dev_path}" with lsblk')
raise err
output = worker.output(remove_cr=False)
return LsblkOutput.model_validate_json(output)
return LsblkOutput.model_validate_json(result.stdout)
def get_lsblk_info(