Skip to content

Commit

Permalink
fix: [main] create parsed_data folder if it does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Oct 21, 2024
1 parent cbd927a commit f7f75c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sysdiagnose/utils/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from abc import ABC, abstractmethod
import os
import json
import sys
from pathlib import Path
from datetime import datetime
import re
Expand All @@ -21,10 +20,14 @@ def __init__(self, cases_path: str):
os.makedirs(self.cases_root_folder, exist_ok=True)

def get_case_data_folder(self, case_id: str) -> str:
return os.path.join(self.cases_root_folder, case_id, 'data')
case_data_folder = os.path.join(self.cases_root_folder, case_id, 'data')
os.makedirs(case_data_folder, exist_ok=True)
return case_data_folder

def get_case_parsed_data_folder(self, case_id: str) -> str:
return os.path.join(self.cases_root_folder, case_id, 'parsed_data')
parsed_data_folder = os.path.join(self.cases_root_folder, case_id, 'parsed_data')
os.makedirs(parsed_data_folder, exist_ok=True)
return parsed_data_folder


class BaseInterface(ABC):
Expand Down
2 changes: 2 additions & 0 deletions src/sysdiagnose/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# By default, we want to have the possibility to log almost everything.
logger.setLevel(logging.INFO)


class SysdiagnoseJsonFormatter(jsonlogger.JsonFormatter):
'''Custom JSON logger formatter '''
# https://stackoverflow.com/questions/50873446/python-logger-output-dates-in-is8601-format
Expand All @@ -29,6 +30,7 @@ def get_console_handler(level: str) -> logging.StreamHandler:

return ch


def get_json_handler(filename: str, level: int = logging.INFO) -> logging.FileHandler:
'''
Creates a logging JSON format file handler.
Expand Down

0 comments on commit f7f75c1

Please sign in to comment.