From bd8df0f5d72fba022ae42ca512287dfa2e3d547a Mon Sep 17 00:00:00 2001 From: Rich Bell Date: Fri, 8 Mar 2024 14:26:49 -0500 Subject: [PATCH] validate the configuration to be parsed --- bin/user/MQTTSubscribe.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/user/MQTTSubscribe.py b/bin/user/MQTTSubscribe.py index 209c6a4..c1f0023 100755 --- a/bin/user/MQTTSubscribe.py +++ b/bin/user/MQTTSubscribe.py @@ -2658,12 +2658,31 @@ def __init__(self, parser, options): if topics_dict is None: raise ValueError("[[topics]] is required.") + self._validate() + message_callback_config = self.config_dict.get('message_callback', None) logger = Logger('Service', level=options.log_level, filename=options.log_file, console=options.console) self.manager = TopicManager(None, topics_dict, logger) self.message_callback_provider = MessageCallbackProvider(message_callback_config, logger, self.manager) + def _validate(self): + config_spec = configobj.ConfigObj(CONFIG_SPEC_TEXT.splitlines()) + mqttsubscribe_configuration = MQTTSubscribeConfiguration(None) + error_msgs = [] + warn_msgs = [] + mqttsubscribe_configuration.validate(self.section, + "", + self.config_dict, + config_spec['MQTTSubscribe'], + MQTTSubscribeConfiguration.deprecated_options, + error_msgs, + warn_msgs) + for msg in warn_msgs: + print(msg) + for msg in error_msgs: + print(msg) + def parse(self): ''' Parse it''' payload = ''