summaryrefslogtreecommitdiffstats
path: root/src/utils/hw_inventory.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/hw_inventory.py')
-rw-r--r--src/utils/hw_inventory.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/utils/hw_inventory.py b/src/utils/hw_inventory.py
index c534101..7341dac 100644
--- a/src/utils/hw_inventory.py
+++ b/src/utils/hw_inventory.py
@@ -10,6 +10,7 @@ import json
import os.path
import shlex
import subprocess
+from src.log import OgError
from collections import namedtuple
from enum import Enum, auto
@@ -55,16 +56,16 @@ class HardwareInventory():
def add_element(self, elem):
if elem.type not in HardwareType:
- raise ValueError(f'Unsupported hardware type, received {elem.type}')
+ raise OgError(f'Unsupported hardware type, received {elem.type}')
if not elem.name:
- raise ValueError('Empty hardware element name')
+ raise OgError('Empty hardware element name')
self.elements.append(elem)
def _bytes_to_human(size):
suffixes = ['B', 'MiB', 'GiB', 'TiB']
if type(size) is not int:
- raise TypeError(f'Invalid type in _bytes_to_human, got: {size} {type(size)}')
+ raise OgError(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:
@@ -250,7 +251,7 @@ def legacy_hardware_element(element):
represented as "vga=Foo"
"""
if type(element) is not HardwareElement:
- raise TypeError('Invalid hardware element type')
+ raise OgError('Invalid hardware element type')
elif element.type is HardwareType.MULTIMEDIA:
nemonic = 'mul'
elif element.type is HardwareType.BOOTMODE:
@@ -297,7 +298,7 @@ def get_hardware_inventory():
if type(j) is list:
root = j[0]
if type(root) is not dict:
- raise ValueError('Invalid lshw json output')
+ raise OgError('Invalid lshw json output')
inventory = HardwareInventory()
_fill_computer_model(inventory, root)