1
0

config.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. """Module core/configs provide project base settings"""
  2. import glob
  3. import json
  4. import logging
  5. import os
  6. import os.path
  7. class Settings:
  8. PROJECT_NAME: str = 'Kraken'
  9. DEVICE = 'neo'
  10. CONFIG_INFO = {
  11. 'host': '127.0.0.1',
  12. 'port': 8712,
  13. 'channel_count': 9,
  14. 'sample_rate': 1000,
  15. 'delay_milliseconds': 40,
  16. 'buffer_plot_size_seconds': 0.04,
  17. 'channel_labels': [
  18. 'CH001',
  19. 'CH002',
  20. 'CH003',
  21. 'CH004',
  22. 'CH005',
  23. 'CH006',
  24. 'CH007',
  25. 'CH008',
  26. 'STIM'
  27. ],
  28. 'strips': [['CH001', 'CH002', 'CH003', 'CH004'],
  29. ['CH005', 'CH006', 'CH007', 'CH008']],
  30. }
  31. FINGERMODEL_IDS = {
  32. 'rest': 0,
  33. 'cylinder': 1,
  34. 'ball': 2,
  35. 'flex': 3,
  36. 'double': 4,
  37. 'treble': 5
  38. }
  39. PROJECT_VERSION: str = '0.0.1'
  40. DATA_PATH = './data'
  41. def __init__(self):
  42. self.config = {"lang": "zh"}
  43. def get_message(self):
  44. self.message = {}
  45. msg_list = glob.glob('./static/config/message*.json')
  46. for msg in msg_list:
  47. filename = os.path.basename(msg)
  48. msg_code, ext = os.path.splitext(filename)
  49. with open(msg, 'r', encoding='utf8') as file:
  50. self.message[msg_code.split('_')[1]] = json.load(file)
  51. return self.message
  52. settings = Settings()
  53. def setup_logging(default_path='logging.json',
  54. default_level=logging.INFO,
  55. env_key='LOG_CFG'):
  56. """Setup logging configuration
  57. """
  58. path = default_path
  59. value = os.getenv(env_key, None)
  60. if value:
  61. path = value
  62. if os.path.exists(path):
  63. with open(path, 'rt', encoding='utf-8') as f:
  64. config = json.load(f)
  65. logging.config.dictConfig(config)
  66. else:
  67. logging.basicConfig(level=default_level)
  68. def set_deepface_env():
  69. # os.environ['DEEPFACE_HOME'] = Path(__file__).resolve().parent.as_posix()
  70. os.environ['DEEPFACE_HOME'] = settings.get_resource_dir(['']).as_posix()