Skip to content

Commit

Permalink
validate the configuration to be parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
bellrichm committed Mar 8, 2024
1 parent c6af909 commit bd8df0f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bin/user/MQTTSubscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down

0 comments on commit bd8df0f

Please sign in to comment.