Skip to content

Commit

Permalink
fix: [appinstallation] catch error if no files match
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Oct 21, 2024
1 parent 64dbaf9 commit cbd927a
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/sysdiagnose/parsers/appinstallation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,26 @@ def get_log_files(self) -> list:
def execute(self) -> list | dict:
try:
result = []
db_json = misc.json_serializable(sqlite2json.sqlite2struct(self.get_log_files()[0]))
skipped = set()
for key, values in db_json.items():
if 'sqlite_sequence' in key:
continue
for value in values:
if 'timestamp' not in value:
skipped.add(key)
for filename in self.get_log_files()[0]:
db_json = misc.json_serializable(sqlite2json.sqlite2struct(filename))
skipped = set()
for key, values in db_json.items():
if 'sqlite_sequence' in key:
continue

try:
timestamp = datetime.fromtimestamp(value['timestamp'], tz=timezone.utc)
value['db_table'] = key
value['datetime'] = timestamp.isoformat(timespec='microseconds')
value['timestamp'] = timestamp.timestamp()
result.append(value)
except TypeError:
# skip "None" values and such
pass
for value in values:
if 'timestamp' not in value:
skipped.add(key)
continue

try:
timestamp = datetime.fromtimestamp(value['timestamp'], tz=timezone.utc)
value['db_table'] = key
value['datetime'] = timestamp.isoformat(timespec='microseconds')
value['timestamp'] = timestamp.timestamp()
result.append(value)
except TypeError:
# skip "None" values and such
pass
return result
except IndexError:
logger.exception("Index error, returning empty list")
Expand Down

0 comments on commit cbd927a

Please sign in to comment.