From 6a6a400320bc61f37ccca12d656a4d4742c74783 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sun, 9 Mar 2025 22:09:24 -0400 Subject: [PATCH] adjust regex --- hwmonDaemon.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hwmonDaemon.py b/hwmonDaemon.py index e487e66..14d955f 100644 --- a/hwmonDaemon.py +++ b/hwmonDaemon.py @@ -785,7 +785,8 @@ class SystemHealthMonitor: size_str = size_str.strip().upper() - match = re.match(r'^([\d.]+)\s*([KMGT])B?$', size_str) + # Match size with optional decimal and unit + match = re.match(r'^([\d.]+)\s*([KMGT]B?)?$', size_str) if match: value = float(match.group(1)) unit = match.group(2) @@ -794,13 +795,18 @@ class SystemHealthMonitor: 'K': 1024, 'M': 1024**2, 'G': 1024**3, - 'T': 1024**4 + 'T': 1024**4, + 'KB': 1024, + 'MB': 1024**2, + 'GB': 1024**3, + 'TB': 1024**4 } return value * multipliers.get(unit, 1) # Default to 1 for bytes return 0.0 + def _is_physical_disk(self, device_path): """ Check if the device is a physical disk, excluding logical volumes and special devices.