LXC Storage Parsing Fragility #11

Open
opened 2026-02-02 14:47:10 -05:00 by jared · 0 comments
Owner

Lines 2225-2260: The column index parsing assumes fixed format:

columns = fs_line.split()
if len(columns) >= 6:
total_space = self._parse_size(columns[2]) # Fragile!

Improvement - use regex for robustness:

Match: filesystem size used avail use% mountpoint

match = re.match(r'(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\d+)%\s+(.+)', fs_line)
if match:
_, total, used, avail, percent, mountpoint = match.groups()
total_space = self._parse_size(total)
# ...

Lines 2225-2260: The column index parsing assumes fixed format: columns = fs_line.split() if len(columns) >= 6: total_space = self._parse_size(columns[2]) # Fragile! Improvement - use regex for robustness: # Match: filesystem size used avail use% mountpoint match = re.match(r'(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\d+)%\s+(.+)', fs_line) if match: _, total, used, avail, percent, mountpoint = match.groups() total_space = self._parse_size(total) # ...
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/hwmonDaemon#11