From 77242a8ea0658def57cc63a1ddac84200379378c Mon Sep 17 00:00:00 2001 From: lingfish Date: Mon, 9 Dec 2024 17:28:16 +1100 Subject: [PATCH] FLEX fixes. This should partially fix crashes around FLEX; it needs improvement to better handle FLEX fragments, and will just currently output everything that it sees from multimon-ng. Some detail at https://github.com/lingfish/mmng-ui/issues/3 Changelog: fixed --- src/mmng_ui/reader.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mmng_ui/reader.py b/src/mmng_ui/reader.py index 2d3ac27..119fb4f 100644 --- a/src/mmng_ui/reader.py +++ b/src/mmng_ui/reader.py @@ -122,7 +122,7 @@ def parse(self, line: str) -> tuple[PocsagMessage, bool]: elif re.search(r'FLEX[:|]', line): address_match = re.search(r'FLEX[:|] ?.*?[\[|](\d*?)[\]| ]', line) if address_match: - address = address_match.group(1).trim() + address = address_match.group(1).strip() # Handle timestamps within FLEX if self.use_timestamp: @@ -155,8 +155,12 @@ def parse(self, line: str) -> tuple[PocsagMessage, bool]: frag[address] = message trim_message = '' elif re.search(r'[ |][0-9]{4}\/[0-9]\/C\/.[ |]', line): - trim_message = frag[address] + message - del frag[address] + try: + trim_message = frag[address] + message + del frag[address] + except KeyError: + # We've seen a fragment without the starting frag, treat as final + trim_message = message else: trim_message = message