this aint gonna work

This commit is contained in:
2025-03-09 21:03:21 -04:00
parent c0a70c5cdf
commit e9fc632086

View File

@ -781,19 +781,38 @@ class SystemHealthMonitor:
def _parse_size(self, size_str: str) -> float:
"""Parse size string with units to bytes"""
logger.debug(f"Parsing size string: {size_str}")
match = re.match(r'([\d.]+)\s*([KMGT])', size_str.strip())
# Handle empty or invalid input
if not size_str or not isinstance(size_str, str):
return 0.0
# Remove any whitespace and handle M/G/T units
size_str = size_str.strip()
# Handle values with decimal points (like 192.2M)
match = re.match(r'^([\d.]+)\s*([KMGT])?', size_str)
if match:
value = float(match.group(1))
unit = match.group(2)
unit = match.group(2) if match.group(2) else 'B'
multipliers = {
'B': 1,
'K': 1024,
'M': 1024**2,
'M': 1024**2,
'G': 1024**3,
'T': 1024**4
}
return value * multipliers[unit]
logger.debug(f"Parsed value: {value}, Unit: {unit}, Result: {value * multipliers[unit]}")
return float(size_str)
result = value * multipliers[unit]
logger.debug(f"Parsed value: {value}, Unit: {unit}, Result: {result}")
return result
# If no match, try to convert directly to float
try:
return float(size_str)
except ValueError:
logger.debug(f"Could not parse size string: {size_str}")
return 0.0
def _is_physical_disk(self, device_path):
"""