From 3d73e1a368f7b14ed02283bfd982af3d92be164e Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 18 May 2022 18:00:54 +0200 Subject: [PATCH] fix version in snaposhotslog --- ereuse_devicehub/parser/computer.py | 14 ++++++++++---- ereuse_devicehub/parser/parser.py | 11 ++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ereuse_devicehub/parser/computer.py b/ereuse_devicehub/parser/computer.py index fb964808..a6993c04 100644 --- a/ereuse_devicehub/parser/computer.py +++ b/ereuse_devicehub/parser/computer.py @@ -422,7 +422,7 @@ class Computer(Device): self._ram = None @classmethod - def run(cls, lshw, hwinfo_raw, uuid=None, sid=None): + def run(cls, lshw, hwinfo_raw, uuid=None, sid=None, version=None): """ Gets hardware information from the computer and its components, like serial numbers or model names, and benchmarks them. @@ -447,18 +447,24 @@ class Computer(Device): txt = "Error: Snapshot: {uuid}, sid: {sid}, type_error: {type}, error: {error}".format( uuid=uuid, sid=sid, type=err.__class__, error=err ) - cls.errors(txt, uuid=uuid, sid=sid) + cls.errors(txt, uuid=uuid, sid=sid, version=version) return computer, components @classmethod - def errors(cls, txt=None, uuid=None, sid=None, severity=Severity.Error): + def errors( + cls, txt=None, uuid=None, sid=None, version=None, severity=Severity.Error + ): if not txt: return logger.error(txt) error = SnapshotsLog( - description=txt, snapshot_uuid=uuid, severity=severity, sid=sid + description=txt, + snapshot_uuid=uuid, + severity=severity, + sid=sid, + version=version, ) error.save() diff --git a/ereuse_devicehub/parser/parser.py b/ereuse_devicehub/parser/parser.py index 7d5f6db9..f20d91d9 100644 --- a/ereuse_devicehub/parser/parser.py +++ b/ereuse_devicehub/parser/parser.py @@ -320,6 +320,7 @@ class ParseSnapshotLsHw: self.default = default self.uuid = snapshot.get("uuid") self.sid = snapshot.get("sid") + self.version = snapshot.get("version") self.dmidecode_raw = snapshot["data"]["dmidecode"] self.smart = snapshot["data"]["smart"] self.hwinfo_raw = snapshot["data"]["hwinfo"] @@ -362,7 +363,7 @@ class ParseSnapshotLsHw: def set_basic_datas(self): try: pc, self.components_obj = Computer.run( - self.lshw, self.hwinfo_raw, self.uuid, self.sid + self.lshw, self.hwinfo_raw, self.uuid, self.sid, self.version ) pc = pc.dump() minimum_hid = None in [pc['manufacturer'], pc['model'], pc['serialNumber']] @@ -546,13 +547,17 @@ class ParseSnapshotLsHw: return action - def errors(self, txt=None, severity=Severity.Info): + def errors(self, txt=None, severity=Severity.Error): if not txt: return self._errors logger.error(txt) self._errors.append(txt) error = SnapshotsLog( - description=txt, snapshot_uuid=self.uuid, severity=severity, sid=self.sid + description=txt, + snapshot_uuid=self.uuid, + severity=severity, + sid=self.sid, + version=self.version, ) error.save()