diff --git a/evidence/models.py b/evidence/models.py index b410795..6b6069c 100644 --- a/evidence/models.py +++ b/evidence/models.py @@ -63,7 +63,7 @@ class Evidence: def get_phid(self): if not self.doc: self.get_doc() - + return hashlib.sha3_256(json.dumps(self.doc)).hexdigest() def get_doc(self): @@ -89,26 +89,23 @@ class Evidence: self.inxi = ev["output"] else: dmidecode_raw = self.doc["data"]["dmidecode"] + inxi_raw = self.doc["data"]["inxi"] + self.dmi = DMIParse(dmidecode_raw) try: - self.inxi = json.loads(self.doc["data"]["inxi"]) + self.inxi = json.loads(inxi_raw) + machine = get_inxi_key(self.inxi, 'Machine') + for m in machine: + system = get_inxi(m, "System") + if system: + self.device_manufacturer = system + self.device_model = get_inxi(m, "product") + self.device_serial_number = get_inxi(m, "serial") + self.device_chassis = get_inxi(m, "Type") + self.device_version = get_inxi(m, "v") + except Exception: return - self.dmi = DMIParse(dmidecode_raw) - try: - machine = get_inxi_key(self.inxi, 'Machine') - for m in machine: - system = get_inxi(m, "System") - if system: - self.device_manufacturer = system - self.device_model = get_inxi(m, "product") - self.device_serial_number = get_inxi(m, "serial") - self.device_chassis = get_inxi(m, "Type") - self.device_version = get_inxi(m, "v") - - except Exception: - return - def get_time(self): if not self.doc: self.get_doc() @@ -160,6 +157,9 @@ class Evidence: if self.inxi: return self.device_chassis + if self.inxi: + return self.device_chassis + chassis = self.dmi.get("Chassis")[0].get("Type", '_virtual') lower_type = chassis.lower() @@ -177,7 +177,6 @@ class Evidence: return self.dmi.serial_number().strip() - def get_version(self): if self.inxi: return self.device_version diff --git a/evidence/parse.py b/evidence/parse.py index 2f67df6..8e52a09 100644 --- a/evidence/parse.py +++ b/evidence/parse.py @@ -14,7 +14,6 @@ from django.conf import settings if settings.DPP: from dpp.api_dlt import register_device_dlt, register_passport_dlt - logger = logging.getLogger('django')