Skip to content

Commit

Permalink
chg: [main] detect case data_subfolder using sysdiagnose.log
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Nov 7, 2024
1 parent 7b920f9 commit 790b847
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/sysdiagnose/utils/base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from abc import ABC, abstractmethod
import os
import json
from pathlib import Path
from datetime import datetime
import re
from functools import cached_property
from pathlib import Path
from sysdiagnose.utils.logger import logger
import glob
import json
import os
import re


class SysdiagnoseConfig:
Expand Down Expand Up @@ -44,8 +45,13 @@ def __init__(self, module_filename: str, config: SysdiagnoseConfig, case_id: str

self.case_data_folder = config.get_case_data_folder(case_id)
os.makedirs(self.case_data_folder, exist_ok=True)
case_data_folder_dirlist = os.listdir(self.case_data_folder)
self.case_data_subfolder = os.path.join(self.case_data_folder, [item for item in case_data_folder_dirlist if 'sysdiagnose_' in item][0])

# Search for the 'sysdiagnose.log' file and return the parent folder
log_files = glob.glob(os.path.join(self.case_data_folder, '**', 'sysdiagnose.log'), recursive=True)
if log_files:
self.case_data_subfolder = os.path.dirname(log_files[0])
else:
self.case_data_subfolder = self.case_data_folder

self.case_parsed_data_folder = config.get_case_parsed_data_folder(case_id)
os.makedirs(self.case_parsed_data_folder, exist_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion src/sysdiagnose/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def load_plist_string_as_json(plist_string: str) -> dict:
return json_serializable(plist)


def load_plist_bytes_as_json(plist_bytes: bytes):
def load_plist_bytes_as_json(plist_bytes: bytes) -> dict:
plist = nska_deserialize.deserialize_plist_from_string(plist_bytes, full_recurse_convert_nska=True, format=dict)
return json_serializable(plist)

Expand Down

0 comments on commit 790b847

Please sign in to comment.