mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-30 17:50:46 +00:00
collector/dmesg: Handle non-matching regex
Raise an exception allowing diagnosis when a dmesg line does not match the regex it is supposed to, rather than the cryptic groups() AttributeError on None.
This commit is contained in:
parent
3c37bf3de1
commit
3e45a2298e
@ -70,7 +70,7 @@ class KernelLogEntry(object):
|
|||||||
def parse_raw_level(line):
|
def parse_raw_level(line):
|
||||||
match = cls._RAW_LEVEL_REGEX.match(line)
|
match = cls._RAW_LEVEL_REGEX.match(line)
|
||||||
if not match:
|
if not match:
|
||||||
raise ValueError('dmesg entry format not recognized: {}'.format(line))
|
raise ValueError(f'dmesg entry format not recognized: {line}')
|
||||||
level, remainder = match.groups()
|
level, remainder = match.groups()
|
||||||
levels = DmesgCollector.LOG_LEVELS
|
levels = DmesgCollector.LOG_LEVELS
|
||||||
# BusyBox dmesg can output numbers that need to wrap around
|
# BusyBox dmesg can output numbers that need to wrap around
|
||||||
@ -79,11 +79,15 @@ class KernelLogEntry(object):
|
|||||||
|
|
||||||
def parse_pretty_level(line):
|
def parse_pretty_level(line):
|
||||||
match = cls._PRETTY_LEVEL_REGEX.match(line)
|
match = cls._PRETTY_LEVEL_REGEX.match(line)
|
||||||
|
if not match:
|
||||||
|
raise ValueError(f'dmesg entry pretty format not recognized: {line}')
|
||||||
facility, level, remainder = match.groups()
|
facility, level, remainder = match.groups()
|
||||||
return facility, level, remainder
|
return facility, level, remainder
|
||||||
|
|
||||||
def parse_timestamp_msg(line):
|
def parse_timestamp_msg(line):
|
||||||
match = cls._TIMESTAMP_MSG_REGEX.match(line)
|
match = cls._TIMESTAMP_MSG_REGEX.match(line)
|
||||||
|
if not match:
|
||||||
|
raise ValueError(f'dmesg entry timestamp format not recognized: {line}')
|
||||||
timestamp, msg = match.groups()
|
timestamp, msg = match.groups()
|
||||||
timestamp = timedelta(seconds=float(timestamp.strip()))
|
timestamp = timedelta(seconds=float(timestamp.strip()))
|
||||||
return timestamp, msg
|
return timestamp, msg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user