]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1945] take premium exhonerated duplicate messages into account
authorAndrei Pavel <andrei@isc.org>
Mon, 19 Aug 2024 15:09:25 +0000 (18:09 +0300)
committerAndrei Pavel <andrei@isc.org>
Thu, 22 Aug 2024 12:47:23 +0000 (15:47 +0300)
This makes it easier to run `./tools/check-messages.py` to correctly
assess the state of messages while developing Kea without having to
remove the premium directory.

tools/check-messages.py

index d5347a202dcb30d50c8a61d6a49e96002d562def..3ac03052e982447549d734357786a3f38185ff54 100755 (executable)
@@ -29,12 +29,17 @@ This script does several verifications regarding logged messages:
 def check_duplicate_occurences(occurences):
     exhonerated = {}
     parent_dir = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0])))
-    with open(f'{parent_dir}/exhonerated-duplicate-messages.txt', 'r', encoding='utf-8') as f:
-        lines = f.read().splitlines()
-        for line in lines:
-            message_id = line.split('%')[1].split(':')[0].strip()
-            max_allowed = line.split(':')[1].strip()
-            exhonerated[message_id] = int(max_allowed)
+    for exh_txt in [
+        f'{parent_dir}/exhonerated-duplicate-messages.txt',
+        f'{parent_dir}/../premium/tools/exhonerated-duplicate-messages.txt',
+    ]:
+        if pathlib.Path(exh_txt).is_file():
+            with open(exh_txt, 'r', encoding='utf-8') as f:
+                lines = f.read().splitlines()
+                for line in lines:
+                    message_id = line.split('%')[1].split(':')[0].strip()
+                    max_allowed = line.split(':')[1].strip()
+                    exhonerated[message_id] = int(max_allowed)
 
     failure = False
     duplicate_occurences = {k: v for k, v in occurences.items() if v > 1}