From 0bc75ec547c94fb06f3a8e46631ebb433ba08465 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 18 May 2022 18:26:01 +0200 Subject: [PATCH] add get_status --- ereuse_devicehub/parser/models.py | 6 ++++++ ereuse_devicehub/parser/parser.py | 8 ++++---- ereuse_devicehub/templates/inventory/snapshots_list.html | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ereuse_devicehub/parser/models.py b/ereuse_devicehub/parser/models.py index 5f861647..b6e7d2eb 100644 --- a/ereuse_devicehub/parser/models.py +++ b/ereuse_devicehub/parser/models.py @@ -34,3 +34,9 @@ class SnapshotsLog(Thing): if commit: db.session.commit() + + def get_status(self): + if self.severity: + return Severity(self.severity) + + return '' diff --git a/ereuse_devicehub/parser/parser.py b/ereuse_devicehub/parser/parser.py index f20d91d9..ac18a75b 100644 --- a/ereuse_devicehub/parser/parser.py +++ b/ereuse_devicehub/parser/parser.py @@ -422,7 +422,7 @@ class ParseSnapshotLsHw: uuid=self.uuid, size=size, sid=self.sid ) ) - self.errors(txt) + self.errors(txt, severity=Severity.Warning) return 128 size, units = size.split(" ") return base2.Quantity(float(size), units).to('MiB').m @@ -433,7 +433,7 @@ class ParseSnapshotLsHw: txt = "Error: Snapshot: {uuid}, tag: {sid} have this ram Speed: {speed}".format( uuid=self.uuid, speed=speed, sid=self.sid ) - self.errors(txt) + self.errors(txt, severity=Severity.Warning) return 100 speed, units = speed.split(" ") return float(speed) @@ -468,7 +468,7 @@ class ParseSnapshotLsHw: txt = "Error: Snapshot: {uuid} tag: {sid} have this uuid: {device}".format( uuid=self.uuid, device=dmi_uuid, sid=self.sid ) - self.errors(txt) + self.errors(txt, severity=Severity.Warning) dmi_uuid = None return dmi_uuid @@ -515,7 +515,7 @@ class ParseSnapshotLsHw: interface, self.sid ) self.errors("{}".format(err)) - self.errors(txt) + self.errors(txt, severity=Severity.Warning) return "ATA" def get_data_storage_size(self, x): diff --git a/ereuse_devicehub/templates/inventory/snapshots_list.html b/ereuse_devicehub/templates/inventory/snapshots_list.html index 22ecd74d..c9c76a08 100644 --- a/ereuse_devicehub/templates/inventory/snapshots_list.html +++ b/ereuse_devicehub/templates/inventory/snapshots_list.html @@ -54,7 +54,7 @@ {% endif %} - {{ snap.severity }} + {{ snap.get_status() }} {{ snap.description }}