summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/utils/hw_inventory.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/utils/hw_inventory.py b/src/utils/hw_inventory.py
index 2f38ae2..e7cb463 100644
--- a/src/utils/hw_inventory.py
+++ b/src/utils/hw_inventory.py
@@ -64,7 +64,7 @@ class HardwareInventory():
def _bytes_to_human(size):
suffixes = ['B', 'MiB', 'GiB', 'TiB']
if type(size) is not int:
- raise TypeError('Invalid type')
+ raise TypeError(f'Invalid type in _bytes_to_human, got: {size} {type(size)}')
for exponent, suffix in enumerate(suffixes, start=1):
conv = size / (1024**exponent)
if conv < 1024:
@@ -106,11 +106,14 @@ def _process_core_cpu(inventory, obj):
def _process_core_mem_bank(inventory, obj):
slot = obj.get('slot', 'Unknown slot')
- size = _bytes_to_human(obj.get('size', None))
- if size:
- mem = ' '.join([obj.get('vendor', 'Unknown vendor'), obj.get('product', 'Unknown product'), size, f'({slot})'])
- mem_elem = HardwareElement(HardwareType.MEMORY, mem)
- inventory.add_element(mem_elem)
+ if 'size' in obj:
+ size = obj['size']
+ human_size = _bytes_to_human(size)
+ mem = ' '.join([obj.get('vendor', 'Unknown vendor'), obj.get('product', 'Unknown product'), human_size, f'({slot})'])
+ else:
+ mem = ' '.join([obj.get('vendor', 'Unknown vendor'), obj.get('product', 'Unknown product'), 'Empty slot', f'({slot})'])
+ mem_elem = HardwareElement(HardwareType.MEMORY, mem)
+ inventory.add_element(mem_elem)
def _process_core_mem(inventory, obj):