You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
783 B
29 lines
783 B
import json
|
|
from dataclasses import asdict
|
|
|
|
import configSer
|
|
|
|
def test_load_config():
|
|
config_path = "../config.json"
|
|
# 读取配置文件
|
|
config: configSer.ConfigOperate = configSer.ConfigOperate(config_path)
|
|
json_str2 = config.config_info.to_json(indent=4)
|
|
print("json=",json_str2)
|
|
# 测试修改相机id
|
|
config.config_info.capture=1
|
|
config.save2json_file()
|
|
# 更新配置文件
|
|
updates = {
|
|
"capture": "rtsp://admin:123456abc@192.168.1.64:554/h264/ch1/main/av_stream",
|
|
}
|
|
config.update_dict_config(updates)
|
|
|
|
# 重新读取配置文件,确认更新
|
|
updated_config = configSer.ConfigOperate(config_path)
|
|
print(f"当前新配置capture:{updated_config.capture}")
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_load_config()
|