"""Module core/configs provide project base settings""" import glob import json import logging import os import os.path class Settings: PROJECT_NAME: str = 'Kraken' DEVICE = 'neo' CONFIG_INFO = { 'host': '127.0.0.1', 'port': 8712, 'channel_count': 9, 'sample_rate': 1000, 'delay_milliseconds': 40, 'buffer_plot_size_seconds': 0.04, 'channel_labels': [ 'CH001', 'CH002', 'CH003', 'CH004', 'CH005', 'CH006', 'CH007', 'CH008', 'STIM' ], 'strips': [['CH001', 'CH002', 'CH003', 'CH004'], ['CH005', 'CH006', 'CH007', 'CH008']], } FINGERMODEL_IDS = { 'rest': 0, 'cylinder': 1, 'ball': 2, 'flex': 3, 'double': 4, 'treble': 5 } PROJECT_VERSION: str = '0.0.1' DATA_PATH = './data' def __init__(self): self.config = {"lang": "zh"} def get_message(self): self.message = {} msg_list = glob.glob('./static/config/message*.json') for msg in msg_list: filename = os.path.basename(msg) msg_code, ext = os.path.splitext(filename) with open(msg, 'r', encoding='utf8') as file: self.message[msg_code.split('_')[1]] = json.load(file) return self.message settings = Settings() def setup_logging(default_path='logging.json', default_level=logging.INFO, env_key='LOG_CFG'): """Setup logging configuration """ path = default_path value = os.getenv(env_key, None) if value: path = value if os.path.exists(path): with open(path, 'rt', encoding='utf-8') as f: config = json.load(f) logging.config.dictConfig(config) else: logging.basicConfig(level=default_level) def set_deepface_env(): # os.environ['DEEPFACE_HOME'] = Path(__file__).resolve().parent.as_posix() os.environ['DEEPFACE_HOME'] = settings.get_resource_dir(['']).as_posix()