debug parse
This commit is contained in:
@ -778,11 +778,14 @@ 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}")
|
||||
|
||||
if not size_str:
|
||||
return 0.0
|
||||
|
||||
# Handle decimal numbers with units (like 192.2M, 3.5G)
|
||||
match = re.match(r'([\d.]+)\s*([KMGT])', size_str.strip())
|
||||
# Also handle cases with spaces between number and unit
|
||||
match = re.match(r'([\d.]+)\s*([KMGT])(?:iB|B)?', size_str.strip())
|
||||
if match:
|
||||
value = float(match.group(1))
|
||||
unit = match.group(2)
|
||||
@ -792,13 +795,30 @@ class SystemHealthMonitor:
|
||||
'G': 1024**3,
|
||||
'T': 1024**4
|
||||
}
|
||||
return value * multipliers[unit]
|
||||
|
||||
# Remove any non-numeric characters and try parsing
|
||||
cleaned = ''.join(c for c in size_str if c.isdigit() or c == '.')
|
||||
result = value * multipliers[unit]
|
||||
logger.debug(f"Parsed {size_str} to {result} bytes")
|
||||
return result
|
||||
|
||||
# Handle cases like '957.2M'
|
||||
match = re.match(r'([\d.]+)([KMGT])', size_str.strip())
|
||||
if match:
|
||||
value = float(match.group(1))
|
||||
unit = match.group(2)
|
||||
multipliers = {
|
||||
'K': 1024,
|
||||
'M': 1024**2,
|
||||
'G': 1024**3,
|
||||
'T': 1024**4
|
||||
}
|
||||
result = value * multipliers[unit]
|
||||
logger.debug(f"Parsed {size_str} to {result} bytes")
|
||||
return result
|
||||
|
||||
# Try parsing as plain number
|
||||
try:
|
||||
return float(cleaned)
|
||||
return float(size_str)
|
||||
except ValueError:
|
||||
logger.debug(f"Failed to parse size string: {size_str}")
|
||||
return 0.0
|
||||
|
||||
def _is_physical_disk(self, device_path):
|
||||
|
||||
Reference in New Issue
Block a user