better error handling (fixes #739)

This commit is contained in:
Blake Blackshear 2021-02-09 07:35:41 -06:00
parent e299e73a68
commit 513a099c24

View File

@ -461,6 +461,9 @@ class TrackedObjectProcessor(threading.Thread):
crop=snapshot_config.crop,
height=snapshot_config.height
)
if jpg_bytes is None:
logger.warning(f"Unable to save snapshot for {obj.obj_data['id']}.")
else:
with open(os.path.join(CLIPS_DIR, f"{camera}-{obj.obj_data['id']}.jpg"), 'wb') as j:
j.write(jpg_bytes)
event_data['has_snapshot'] = True
@ -475,6 +478,10 @@ class TrackedObjectProcessor(threading.Thread):
crop=mqtt_config.crop,
height=mqtt_config.height
)
if jpg_bytes is None:
logger.warning(f"Unable to send mqtt snapshot for {obj.obj_data['id']}.")
else:
self.client.publish(f"{self.topic_prefix}/{camera}/{obj.obj_data['label']}/snapshot", jpg_bytes, retain=True)
def object_status(camera, object_name, status):