Skip to content

Commit 7030e1e

Browse files
committed
Fix log disk states
1 parent 1464806 commit 7030e1e

File tree

8 files changed

+23
-24
lines changed

8 files changed

+23
-24
lines changed

archinstall/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
debug(f"Graphics devices detected: {SysInfo._graphics_devices().keys()}")
5555

5656
# For support reasons, we'll log the disk layout pre installation to match against post-installation layout
57-
debug(f"Disk states before installing: {disk.disk_layouts()}")
57+
debug(f"Disk states before installing:\n{disk.disk_layouts()}")
5858

5959
parser = ArgumentParser()
6060

archinstall/lib/disk/device_handler.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from parted import Device, Disk, DiskException, FileSystem, Geometry, IOException, Partition, PartitionException, freshDisk, getAllDevices, getDevice, newDisk
1212

1313
from ..exceptions import DiskError, UnknownFilesystemFormat
14-
from ..general import JSON, SysCallError, SysCommand, SysCommandWorker
14+
from ..general import SysCallError, SysCommand, SysCommandWorker
1515
from ..luks import Luks2
1616
from ..output import debug, error, info, log, warn
1717
from ..utils.util import is_subpath
@@ -42,6 +42,7 @@
4242
find_lsblk_info,
4343
get_all_lsblk_info,
4444
get_lsblk_info,
45+
get_lsblk_output,
4546
)
4647

4748

@@ -843,11 +844,9 @@ def udev_sync() -> None:
843844

844845
def disk_layouts() -> str:
845846
try:
846-
lsblk_info = get_all_lsblk_info()
847-
return json.dumps(lsblk_info, indent=4, sort_keys=True, cls=JSON)
847+
lsblk_output = get_lsblk_output()
848848
except SysCallError as err:
849849
warn(f"Could not return disk layouts: {err}")
850850
return ''
851-
except json.decoder.JSONDecodeError as err:
852-
warn(f"Could not return disk layouts: {err}")
853-
return ''
851+
852+
return lsblk_output.model_dump_json(indent=4)

archinstall/lib/disk/device_model.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import json
43
import math
54
import uuid
65
from dataclasses import dataclass, field
@@ -14,7 +13,7 @@
1413

1514
from ..exceptions import DiskError, SysCallError
1615
from ..general import SysCommand
17-
from ..output import debug, error
16+
from ..output import debug
1817
from ..storage import storage
1918

2019
if TYPE_CHECKING:
@@ -1402,7 +1401,7 @@ def _fetch_lsblk_info(
14021401
dev_path: Path | str | None = None,
14031402
reverse: bool = False,
14041403
full_dev_path: bool = False
1405-
) -> list[LsblkInfo]:
1404+
) -> LsblkOutput:
14061405
cmd = ['lsblk', '--json', '--bytes', '--output', ','.join(LsblkInfo.fields())]
14071406

14081407
if reverse:
@@ -1427,27 +1426,28 @@ def _fetch_lsblk_info(
14271426

14281427
raise err
14291428

1430-
try:
1431-
data = json.loads(worker.output(remove_cr=False))
1432-
except json.decoder.JSONDecodeError as err:
1433-
error(f"Could not decode lsblk JSON:\n{worker.output().decode().rstrip()}")
1434-
raise err
1435-
1436-
return LsblkOutput(**data).blockdevices
1429+
output = worker.output(remove_cr=False)
1430+
return LsblkOutput.parse_raw(output)
14371431

14381432

14391433
def get_lsblk_info(
14401434
dev_path: Path | str,
14411435
reverse: bool = False,
14421436
full_dev_path: bool = False
14431437
) -> LsblkInfo:
1444-
if infos := _fetch_lsblk_info(dev_path, reverse=reverse, full_dev_path=full_dev_path):
1445-
return infos[0]
1438+
infos = _fetch_lsblk_info(dev_path, reverse=reverse, full_dev_path=full_dev_path)
1439+
1440+
if infos.blockdevices:
1441+
return infos.blockdevices[0]
14461442

14471443
raise DiskError(f'lsblk failed to retrieve information for "{dev_path}"')
14481444

14491445

14501446
def get_all_lsblk_info() -> list[LsblkInfo]:
1447+
return _fetch_lsblk_info().blockdevices
1448+
1449+
1450+
def get_lsblk_output() -> LsblkOutput:
14511451
return _fetch_lsblk_info()
14521452

14531453

archinstall/scripts/guided.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def perform_installation(mountpoint: Path) -> None:
154154
except:
155155
pass
156156

157-
debug(f"Disk states after installing: {disk.disk_layouts()}")
157+
debug(f"Disk states after installing:\n{disk.disk_layouts()}")
158158

159159

160160
def guided() -> None:

archinstall/scripts/only_hd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def perform_installation(mountpoint: Path) -> None:
5050
target.parent.mkdir(parents=True)
5151

5252
# For support reasons, we'll log the disk layout post installation (crash or no crash)
53-
debug(f"Disk states after installing: {disk.disk_layouts()}")
53+
debug(f"Disk states after installing:\n{disk.disk_layouts()}")
5454

5555

5656
def only_hd() -> None:

archinstall/scripts/swiss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def perform_installation(mountpoint: Path, exec_mode: ExecutionMode) -> None:
228228
except:
229229
pass
230230

231-
debug(f"Disk states after installing: {disk.disk_layouts()}")
231+
debug(f"Disk states after installing:\n{disk.disk_layouts()}")
232232

233233

234234
def swiss() -> None:

examples/interactive_installation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def perform_installation(mountpoint: Path) -> None:
154154
except:
155155
pass
156156

157-
debug(f"Disk states after installing: {disk.disk_layouts()}")
157+
debug(f"Disk states after installing:\n{disk.disk_layouts()}")
158158

159159

160160
def _guided() -> None:

examples/only_hd_installation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def perform_installation(mountpoint: Path) -> None:
5050
target.parent.mkdir(parents=True)
5151

5252
# For support reasons, we'll log the disk layout post installation (crash or no crash)
53-
debug(f"Disk states after installing: {disk.disk_layouts()}")
53+
debug(f"Disk states after installing:\n{disk.disk_layouts()}")
5454

5555

5656
def _only_hd() -> None:

0 commit comments

Comments
 (0)