From ea8bf99f28c1a5496687516db6d6099c2e38f1e7 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 15 Nov 2024 10:45:26 +0100 Subject: [PATCH] inxi --- workbench-script.py | 66 +++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/workbench-script.py b/workbench-script.py index 5c54660..dbc3b97 100644 --- a/workbench-script.py +++ b/workbench-script.py @@ -28,22 +28,6 @@ SNAPSHOT_BASE = { } -## Legacy Functions ## - -def convert_to_legacy_snapshot(snapshot): - snapshot["sid"] = str(uuid.uuid4()).split("-")[1] - snapshot["software"] = "workbench-script" - snapshot["version"] = "dev" - snapshot["schema_api"] = "1.0.0" - snapshot["settings_version"] = "No Settings Version (NaN)" - snapshot["timestamp"] = snapshot["timestamp"].replace(" ", "T") - snapshot["data"]["smart"] = snapshot["data"]["disks"] - snapshot["data"].pop("disks") - snapshot.pop("erase") - snapshot.pop("token_hash") - -## End Legacy Functions ## - ## Utility Functions ## def logs(f): @@ -71,6 +55,34 @@ def exec_cmd_erase(cmd): ## End Utility functions ## +## Legacy Functions ## + +def convert_to_legacy_snapshot(snapshot): + snapshot["sid"] = str(uuid.uuid4()).split("-")[1] + snapshot["software"] = "workbench-script" + snapshot["version"] = "dev" + snapshot["schema_api"] = "1.0.0" + snapshot["settings_version"] = "No Settings Version (NaN)" + snapshot["timestamp"] = snapshot["timestamp"].replace(" ", "T") + snapshot["data"]["smart"] = snapshot["data"]["disks"] + snapshot["data"].pop("disks") + snapshot.pop("erase") + snapshot.pop("token_hash") + + lshw = 'sudo lshw -xml' + hwinfo = 'sudo hwinfo --reallyall' + dmidecode = 'sudo dmidecode' + lspci = 'sudo lspci -vv' + + data = { + 'lshw': exec_cmd(lshw) or "{}", + 'hwinfo': exec_cmd(hwinfo), + 'lspci': exec_cmd(lspci) + } + snapshot['data'].update(data) + +## End Legacy Functions ## + ## Command Functions ## ## Erase Functions ## @@ -241,37 +253,19 @@ def smartctl(all_disks, disk=None): return data_list -@logs -def inxi(): - filename = "hw.json" - command = 'sudo inxi' - options = '-a -x 3 -f -m -n --edid -G -E -M -A -B -D --output json --output-file' - cmd = f"{command} {options} {filename}" - exec_cmd(cmd) - with open(filename) ad f: - data = f.read() - rm = f"rm -f {filename}" - os.popen(rm).read() - return data - ## End Command Functions ## # TODO permitir selección # TODO permitir que vaya más rápido def get_data(all_disks): - lshw = 'sudo lshw -xml' - hwinfo = 'sudo hwinfo --reallyall' dmidecode = 'sudo dmidecode' - lspci = 'sudo lspci -vv' + inxi = "sudo inxi -afmnGEMABD -x 3 --edid --output json --output-file print" data = { - 'lshw': exec_cmd(lshw) or "{}", 'disks': smartctl(all_disks), - 'hwinfo': exec_cmd(hwinfo), 'dmidecode': exec_cmd(dmidecode), - 'lspci': exec_cmd(lspci) - 'inxi': exec_inxi() + 'inxi': exec_cmd(inxi) } return data