Skip to content

Commit

Permalink
chg: [crashlogs] allow processing of multiple folders ignoring duplic…
Browse files Browse the repository at this point in the history
…ates #99
  • Loading branch information
cvandeplas committed Sep 23, 2024
1 parent 2395952 commit 9915d8b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions parsers/crashlogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_log_files(self) -> list:
def execute(self) -> list | dict:
files = self.get_log_files()
result = []
# TODO ensure no duplicates, see issue #99
seen = set()
for file in files:
print(f"Processing file: {file}")
if file.endswith('crashes_and_spins.log'):
Expand All @@ -52,7 +52,13 @@ def execute(self) -> list | dict:
pass
elif file.endswith('.ips'):
try:
result.append(CrashLogsParser.parse_ips_file(file))
ips = CrashLogsParser.parse_ips_file(file)
ips_hash = f"{ips.get('timestamp', '')}-{ips.get('app_name', '')}"
# skip duplicates
if ips_hash in seen:
continue
seen.add(ips_hash)
result.append(ips)
except Exception as e:
print(f"Skipping file due to error {file}: {e}")
return result
Expand Down

0 comments on commit 9915d8b

Please sign in to comment.