linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rteval: Catch failures in python-dmidecode
@ 2023-02-02 19:29 John Kacur
  0 siblings, 0 replies; only message in thread
From: John Kacur @ 2023-02-02 19:29 UTC (permalink / raw)
  To: RT; +Cc: Clark Williams, John Kacur

python-dmidecode can generate incorrect xml,
namely Attribute unit redefined

Although useful, the dmidecode is not critical to rteval reporting.

Therefore catch this, and first see if we can at least query the bios.
If that works report the bios instead off all, and if that
doesn't work, just continue without the dmidecode report.

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 rteval/sysinfo/dmi.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/rteval/sysinfo/dmi.py b/rteval/sysinfo/dmi.py
index 83f347623b58..89a7faae06b1 100644
--- a/rteval/sysinfo/dmi.py
+++ b/rteval/sysinfo/dmi.py
@@ -79,6 +79,7 @@ class DMIinfo:
 
     def __init__(self, logger=None):
         self.__version = '0.6'
+        self._log = logger
 
         if not dmidecode_avail:
             logger.log(Log.DEBUG, "DMI info unavailable, ignoring DMI tables")
@@ -115,7 +116,18 @@ class DMIinfo:
             rep_n.newProp("not_available", "1")
         else:
             self.__dmixml.SetResultType(dmidecode.DMIXML_DOC)
-            dmiqry = xmlout.convert_libxml2_to_lxml_doc(self.__dmixml.QuerySection('all'))
+            try:
+                dmiqry = xmlout.convert_libxml2_to_lxml_doc(self.__dmixml.QuerySection('all'))
+            except Exception as ex1:
+                self._log.log(Log.DEBUG, f'** EXCEPTION {str(ex1)}, will query BIOS only')
+                try:
+                    # If we can't query 'all', at least query 'bios'
+                    dmiqry = xmlout.convert_libxml2_to_lxml_doc(self.__dmixml.QuerySection('bios'))
+                except Exception as ex2:
+                    rep_n.addContent("No DMI tables available")
+                    rep_n.newProp("not_available", "1")
+                    self._log.log(Log.DEBUG, f'** EXCEPTION {str(ex2)}, dmi info will not be reported')
+                    return rep_n
             resdoc = self.__xsltparser(dmiqry)
             dmi_n = xmlout.convert_lxml_to_libxml2_nodes(resdoc.getroot())
             rep_n.addChild(dmi_n)
-- 
2.39.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-02 19:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02 19:29 [PATCH] rteval: Catch failures in python-dmidecode John Kacur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).