inxi
This commit is contained in:
parent
eac898964f
commit
ea8bf99f28
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue