mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
import os
|
|
from config.config_loader import read_config, get_project_dir, load_config
|
|
|
|
|
|
default_config_file = "config.yaml"
|
|
config_file_valid = False
|
|
|
|
|
|
def check_config_file():
|
|
global config_file_valid
|
|
if config_file_valid:
|
|
return
|
|
"""
|
|
Simplified configuration checks that only prompt users for profile usage
|
|
"""
|
|
custom_config_file = get_project_dir() + "data/." + default_config_file
|
|
if not os.path.exists(custom_config_file):
|
|
raise FileNotFoundError(
|
|
"The data/.config.yaml file cannot be found. Please follow the tutorial to confirm whether the configuration file exists."
|
|
)
|
|
|
|
# Check if configuration is read from api
|
|
config = load_config()
|
|
if config.get("read_config_from_api", False):
|
|
print("Read configuration from api")
|
|
old_config_origin = read_config(custom_config_file)
|
|
if old_config_origin.get("selected_module") is not None:
|
|
error_msg = "Your configuration file seems to contain both the smart console configuration and the local configuration:\n"
|
|
error_msg += "\N recommends that you:\n"
|
|
error_msg += "1. Copy the config from api.yaml file in the root directory to data and rename it to .config.yaml\n"
|
|
error_msg += "2. Configure the interface address and key according to the tutorial\n"
|
|
raise ValueError(error_msg)
|
|
config_file_valid = True
|