diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-12-11 13:36:16 +0100 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-12-11 15:17:02 +0100 |
commit | bf1549143515d9054b2d66a3a270bc8c2398193c (patch) | |
tree | 7ad525dd8b47d0cfeaf9976e1f423ecfa9046b82 /src/utils/hw_inventory.py | |
parent | 855768e1448e39012ea35964306f57586852f417 (diff) |
hw_inventory: fix json parsing
Add support for both lshw -json return formats.
The json structure may follow one of the following.
output:list flag enabled:
[{content}]
output:list flag disabled:
{content}
The output:list flag was defined in the commit 2b1c730 of
https://ezix.org/src/pkg/lshw
Diffstat (limited to 'src/utils/hw_inventory.py')
-rw-r--r-- | src/utils/hw_inventory.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/hw_inventory.py b/src/utils/hw_inventory.py index 9bf826e..09a9fae 100644 --- a/src/utils/hw_inventory.py +++ b/src/utils/hw_inventory.py @@ -293,10 +293,10 @@ def legacy_list_hardware_inventory(inventory): def get_hardware_inventory(): proc = subprocess.run(['lshw', '-json'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) - j = json.loads(proc.stdout) + root = json.loads(proc.stdout) - if type(j) is list: - root = j[0] + if type(root) is list: + root = root[0] if type(root) is not dict: raise OgError('Invalid lshw json output') |