From 3c18fc8903adad9da7a2af84672cd37d60be85c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C5=A0ari=C4=87?= Date: Sat, 16 Dec 2023 16:47:03 +0100 Subject: [PATCH] improve logging, make read channels a csl --- face_recog/detector.py | 5 +++-- main.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/face_recog/detector.py b/face_recog/detector.py index 14b9aac..54ddfcc 100644 --- a/face_recog/detector.py +++ b/face_recog/detector.py @@ -31,8 +31,9 @@ def detect(self, image_url): for d_embedding in detected_embeddings: box = boxes[detected_embeddings.index(d_embedding)] if self._is_match(existing, d_embedding): - logging.info("Found match") - recognized.append((existing["name"], box)) + name = existing["name"] + logging.info(f"Found match - {name}") + recognized.append((name, box)) else: unknown.append(box) diff --git a/main.py b/main.py index 22f06f8..5affc2d 100644 --- a/main.py +++ b/main.py @@ -9,10 +9,10 @@ class DetectorFacade: - def __init__(self, detector, slack_verification_token, read_channel): + def __init__(self, detector, slack_verification_token, read_channels): self.detector = detector self.slack_verification_token = slack_verification_token - self.read_channel = read_channel + self.read_channels = read_channels def process(self, content): if content["token"] != self.slack_verification_token: @@ -21,7 +21,7 @@ def process(self, content): if "event" in content and "files" in content["event"]: app.logger.info("Received event contains files") # TODO: switch to manageable list of channel ids - if content["event"]["channel"] == self.read_channel: + if content["event"]["channel"] in self.read_channels: detector.detect(content["event"]["files"][0]["url_private_download"]) else: app.logger.info(f'Channel ID {content["event"]["channel"]} is not on read list. Skipping event')