From 97d67c6e6fd94a5a2001c2346003cdff93704e38 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sun, 9 Mar 2025 20:37:27 -0400 Subject: [PATCH] Edit parsing again --- hwmonDaemon.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hwmonDaemon.py b/hwmonDaemon.py index fa8ef14..7be94a0 100644 --- a/hwmonDaemon.py +++ b/hwmonDaemon.py @@ -777,12 +777,12 @@ class SystemHealthMonitor: return False def _parse_size(self, size_str: str) -> float: - """Parse size string with units to float value""" + """Parse size string with units to bytes""" if not size_str: return 0.0 - # Handle M/G/T sizes with potential decimal points - match = re.match(r'([\d.]+)([KMGT])', size_str.strip()) + # Handle decimal numbers with units (like 192.2M, 3.5G) + match = re.match(r'([\d.]+)\s*([KMGT])', size_str.strip()) if match: value = float(match.group(1)) unit = match.group(2) @@ -793,14 +793,14 @@ class SystemHealthMonitor: 'T': 1024**4 } return value * multipliers[unit] - - # Try parsing as plain number + + # Remove any non-numeric characters and try parsing + cleaned = ''.join(c for c in size_str if c.isdigit() or c == '.') try: - return float(size_str) + return float(cleaned) except ValueError: return 0.0 - def _is_physical_disk(self, device_path): """ Check if the device is a physical disk, excluding logical volumes and special devices.