From 6d0c55e5d610abd199c1dc0430576535dab894b7 Mon Sep 17 00:00:00 2001 From: Werner Llácer Date: Mon, 8 Nov 2021 14:32:47 +0100 Subject: Solves issue #674 We turned the size query of the devices to byte mode in lsblk (lsblk -b) It avoids problems with the localized output of the lsblk utility. --- archinstall/lib/disk/blockdevice.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py index f80f57f3..8db52330 100644 --- a/archinstall/lib/disk/blockdevice.py +++ b/archinstall/lib/disk/blockdevice.py @@ -5,6 +5,8 @@ from ..exceptions import DiskError from ..output import log from ..general import SysCommand +GIGA=2**30 + class BlockDevice: def __init__(self, path, info=None): if not info: @@ -152,20 +154,11 @@ class BlockDevice: return partition.get('uuid', None) def convert_size_to_gb(self, size): - units = { - 'P' : lambda s : float(s) * 2048, - 'T' : lambda s : float(s) * 1024, - 'G' : lambda s : float(s), - 'M' : lambda s : float(s) / 1024, - 'K' : lambda s : float(s) / 2048, - 'B' : lambda s : float(s) / 3072, - } - unit = size[-1] - return float(units.get(unit, lambda s : None)(size[:-1])) + return size / GIGA @property def size(self): - output = json.loads(SysCommand(f"lsblk --json -o+SIZE {self.path}").decode('UTF-8')) + output = json.loads(SysCommand(f"lsblk --json -b -o+SIZE {self.path}").decode('UTF-8')) for device in output['blockdevices']: return self.convert_size_to_gb(device['size']) -- cgit v1.2.3-70-g09d2 From 80a406c930df436f712f0327613544f0e177ac91 Mon Sep 17 00:00:00 2001 From: Werner Llácer Date: Mon, 8 Nov 2021 19:58:11 +0100 Subject: Followup to the previous one. Output of size function is rounded to the first decimal so output doesn't look too cluttered --- archinstall/lib/disk/blockdevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py index 8db52330..2a6d1cc8 100644 --- a/archinstall/lib/disk/blockdevice.py +++ b/archinstall/lib/disk/blockdevice.py @@ -154,7 +154,7 @@ class BlockDevice: return partition.get('uuid', None) def convert_size_to_gb(self, size): - return size / GIGA + return round(size / GIGA,1) @property def size(self): -- cgit v1.2.3-70-g09d2