mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-16 20:41:13 +00:00
fix: allow empty mqtt file config
This commit is contained in:
@@ -75,20 +75,29 @@ def _update_config_from_module(module):
|
|||||||
# 需要先判断是否为相对路径
|
# 需要先判断是否为相对路径
|
||||||
if MQConfig.ca_file.startswith("."):
|
if MQConfig.ca_file.startswith("."):
|
||||||
MQConfig.ca_file = os.path.join(BasicConfig.config_path, MQConfig.ca_file)
|
MQConfig.ca_file = os.path.join(BasicConfig.config_path, MQConfig.ca_file)
|
||||||
with open(MQConfig.ca_file, "r", encoding="utf-8") as f:
|
if len(MQConfig.ca_file) != 0:
|
||||||
MQConfig.ca_content = f.read()
|
with open(MQConfig.ca_file, "r", encoding="utf-8") as f:
|
||||||
|
MQConfig.ca_content = f.read()
|
||||||
|
else:
|
||||||
|
logger.warning("Skipping CA file loading, ca_file is empty")
|
||||||
if len(MQConfig.cert_content) == 0:
|
if len(MQConfig.cert_content) == 0:
|
||||||
# 需要先判断是否为相对路径
|
# 需要先判断是否为相对路径
|
||||||
if MQConfig.cert_file.startswith("."):
|
if MQConfig.cert_file.startswith("."):
|
||||||
MQConfig.cert_file = os.path.join(BasicConfig.config_path, MQConfig.cert_file)
|
MQConfig.cert_file = os.path.join(BasicConfig.config_path, MQConfig.cert_file)
|
||||||
with open(MQConfig.cert_file, "r", encoding="utf-8") as f:
|
if len(MQConfig.ca_file) != 0:
|
||||||
MQConfig.cert_content = f.read()
|
with open(MQConfig.cert_file, "r", encoding="utf-8") as f:
|
||||||
|
MQConfig.cert_content = f.read()
|
||||||
|
else:
|
||||||
|
logger.warning("Skipping cert file loading, cert_file is empty")
|
||||||
if len(MQConfig.key_content) == 0:
|
if len(MQConfig.key_content) == 0:
|
||||||
# 需要先判断是否为相对路径
|
# 需要先判断是否为相对路径
|
||||||
if MQConfig.key_file.startswith("."):
|
if MQConfig.key_file.startswith("."):
|
||||||
MQConfig.key_file = os.path.join(BasicConfig.config_path, MQConfig.key_file)
|
MQConfig.key_file = os.path.join(BasicConfig.config_path, MQConfig.key_file)
|
||||||
with open(MQConfig.key_file, "r", encoding="utf-8") as f:
|
if len(MQConfig.ca_file) != 0:
|
||||||
MQConfig.key_content = f.read()
|
with open(MQConfig.key_file, "r", encoding="utf-8") as f:
|
||||||
|
MQConfig.key_content = f.read()
|
||||||
|
else:
|
||||||
|
logger.warning("Skipping key file loading, key_file is empty")
|
||||||
|
|
||||||
|
|
||||||
def load_config(config_path=None):
|
def load_config(config_path=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user