Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-11-09 07:49:30 +0000
committerGitHub <noreply@github.com>2021-11-09 07:49:30 +0000
commit992c945b52fab7ec017de211a75158e34c26571c (patch)
tree83ca8833e751fc30fd3048f9678a1e34cbbf64e7 /archinstall/lib
parent8e5869d106f4ddbaf9d8ae87e364a069ae5a923b (diff)
parent80a406c930df436f712f0327613544f0e177ac91 (diff)
Merge pull request #695 from wllacer/master
Solves issue #674
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/disk/blockdevice.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py
index f80f57f3..2a6d1cc8 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 round(size / GIGA,1)
@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'])