mirror of https://git.48k.eu/ogclient
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/lshwmaster
parent
855768e144
commit
bf15491435
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in New Issue