12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- """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': [
- 'C3',
- 'FC3',
- 'CP5',
- 'CP1',
- 'C4',
- 'FC4',
- 'CP2',
- 'CP6',
- 'FP1'
- ]
- }
- PROJECT_VERSION: str = '0.0.1'
- DATA_PATH = './db/data'
- TRAIN_PARAMS = {
- 'instruct_duration': 2 * 1000,
- 'rest_stim_duration': 60 * 1000,
- 'prepare_duration': 1.5 * 1000,
- 'mi_duration': 5 * 1000,
- 'rest_duration': 5 * 1000,
- 'sample_duration': 3 * 1000 # 训练样本长度
- } # milliseconds
- 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()
|