Bug fix for exception counting. Remake for report comparisons.

This commit is contained in:
devin148 2012-08-22 17:17:24 -04:00
parent 3d3e4ec4b6
commit 06e920cd1f

View File

@ -840,20 +840,21 @@ def csv_header(csv_path):
csv.write(output) csv.write(output)
csv.close() csv.close()
# Returns a list of all the exceptions listed in all the case logs # Returns a list of all the exceptions listed in all the autopsy logs
def get_exceptions(): def get_exceptions():
exceptions = [] exceptions = []
logs_path = make_local_path(case.output_dir, case.image_name, "logs") logs_path = make_local_path(case.output_dir, case.image_name, "logs")
results = [] results = []
for file in os.listdir(logs_path): for file in os.listdir(logs_path):
log = open(make_path(logs_path, file), "r") if "autopsy" in file:
lines = log.readlines() log = open(make_path(logs_path, file), "r")
ex = re.compile("\SException") lines = log.readlines()
er = re.compile("\SError") ex = re.compile("\SException")
for line in lines: er = re.compile("\SError")
if ex.search(line) or er.search(line): for line in lines:
exceptions.append(line) if ex.search(line) or er.search(line):
log.close() exceptions.append(line)
log.close()
return exceptions return exceptions
# Returns a list of all the warnings listed in the common log # Returns a list of all the warnings listed in the common log
@ -1227,11 +1228,12 @@ def compare_report_files(a_path, b_path):
a_list = split(a, 50) a_list = split(a, 50)
b_list = split(b, 50) b_list = split(b, 50)
exceptions = [] exceptions = []
for a_split, b_split in zip(a_list, b_list): if not len(a_list) == len(b_list):
if a_split != b_split: exceptions.append("The reports do not match.")
exceptions.append("Got:\t\t" + a_split + "\n") test = "The test HTML report has " + str(len(a_list)) + " segments."
exceptions.append("Expected:\t" + b_split + "\n") gold = "The gold HTML report has " + str(len(b_list)) + " segments."
exceptions.append("~~~~~~~~~~\n") exceptions.append(test)
exceptions.append(gold)
return exceptions return exceptions
# Split a string into an array of string of the given size # Split a string into an array of string of the given size