From 20f51e0b25bfa31fc9ed943de3997f1de511e80e Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Mon, 12 May 2025 15:41:01 -0400 Subject: [PATCH] Updated lxc file system matching --- hwmonDaemon.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hwmonDaemon.py b/hwmonDaemon.py index 81406b1..8d50415 100644 --- a/hwmonDaemon.py +++ b/hwmonDaemon.py @@ -790,6 +790,10 @@ class SystemHealthMonitor: try: # Skip non-size strings + if not isinstance(size_str, str): + logger.debug(f"Not a string: {size_str}") + return 0.0 + if not any(unit in size_str.upper() for unit in ['B', 'K', 'M', 'G', 'T']): logger.debug(f"No valid size unit found in: {size_str}") return 0.0 @@ -804,8 +808,8 @@ class SystemHealthMonitor: } # Extract numeric value and unit - value = float(size_str[:-1].strip()) - unit = size_str[-1].upper() + value = float(re.match(r'(\d+\.?\d*)', size_str).group(1)) + unit = re.search(r'([BKMGT])', size_str.upper()).group(1) logger.debug(f"Extracted value: {value}, unit: {unit}") @@ -815,7 +819,7 @@ class SystemHealthMonitor: return bytes_value - except (ValueError, AttributeError) as e: + except (ValueError, AttributeError, TypeError) as e: logger.debug(f"Failed to parse size string: {size_str}") logger.debug(f"Parse error details: {str(e)}") return 0.0