from os import popen import json class HardwareDevice: def __init__(self, hw_path, device, device_class, description): self.hw_path = hw_path self.device = device self.device_class = device_class self.description = description def __str__(self): return f"{self.description}@{self.device}" def get_hardware_info(hw_type: str): hardware_read_process = popen(f"lshw -json -c {hw_type}") hardware = json.loads(hardware_read_process.read()) hardware_read_process.close() for hw in hardware: print(hw["description"]) return hardware get_hardware_info(hw_type="storage")