Add exception to swift-drive-audit if no date in line.
Sometimes there is no date at the beginning of a line in kern.log. Although it does not happen often, there should be a check ensuring the program doesn't crash in case it happens. Added try-except block surrounding parsing string to date format. Change-Id: I44a101266582eea2199189a006afa1037a9bd4ea Fixes: bug #1152658
This commit is contained in:
parent
a8af3835c0
commit
5e427e5e3b
@ -100,8 +100,11 @@ def get_errors(minutes):
|
||||
year -= 1
|
||||
prev_entry_month = log_time_entry[0]
|
||||
log_time_string = '%s %s' % (year, ' '.join(log_time_entry))
|
||||
log_time = datetime.datetime.strptime(
|
||||
log_time_string, '%Y %b %d %H:%M:%S')
|
||||
try:
|
||||
log_time = datetime.datetime.strptime(
|
||||
log_time_string, '%Y %b %d %H:%M:%S')
|
||||
except ValueError:
|
||||
continue
|
||||
if log_time > end_time:
|
||||
for err in error_re:
|
||||
for device in err.findall(line):
|
||||
|
Loading…
x
Reference in New Issue
Block a user