AAREDB: added send_msg_to_db function - needs testing

This commit is contained in:
2025-10-29 14:58:39 +01:00
parent 9adf90a203
commit d8bc6feeef
+14 -1
View File
@@ -171,7 +171,20 @@ class AareWrapper:
sample_event_create=SampleEventCreate(event_type=SampleEventType("Lost")),
)
except Exception as e:
print(e)
logger.error(f"Error sending message to db: {e}")
def send_msg_to_db(self, s: Optional[SampleShortInfo], event_type:Optional[SampleEventType | str], comment: str = ''):
if s is None or event_type is None:
logger.debug(f"sample info or event type is None, skipping message: {event_type} {comment}")
return
if isinstance(event_type, str):
event_type = SampleEventType(event_type)
try:
self.__sample_api.create_sample_event(
sample_id=s.db_id,
sample_event_create=SampleEventCreate(event_type=event_type, comment=comment)
)
except Exception as e:
logger.error(f"Error sending message to db: {e}")
def upload_image(self, sample_id: int, filename: str, bgr_image: np.ndarray):