Mercurial > code > home > repos > mqtt_metrics
comparison mqtt_metrics.py @ 9:789042521535
crash on regexp syntax errors
author | drewp@bigasterisk.com |
---|---|
date | Mon, 12 Aug 2024 13:14:39 -0700 |
parents | 82cec89e6534 |
children |
comparison
equal
deleted
inserted
replaced
8:82cec89e6534 | 9:789042521535 |
---|---|
102 | 102 |
103 def tryConverters(message) -> list[dict]: | 103 def tryConverters(message) -> list[dict]: |
104 metricEvents: list[dict] = [] | 104 metricEvents: list[dict] = [] |
105 matchedPats = [] | 105 matchedPats = [] |
106 for converter in converters: | 106 for converter in converters: |
107 if not (m := re.search(converter.topic_pattern, message['topic'])): | 107 try: |
108 m = re.search(converter.topic_pattern, message['topic']) | |
109 except Exception: | |
110 log.error('re.search', exc_info=True) | |
111 os.abort() | |
112 if not m: | |
108 continue | 113 continue |
109 if not matchedPats: | 114 if not matchedPats: |
110 try: | 115 try: |
111 metricEvents.extend(converter(message, cast(tuple[str], m.groups()))) | 116 metricEvents.extend(converter(message, cast(tuple[str], m.groups()))) |
112 except Exception: | 117 except Exception: |