Skip to content

Commit

Permalink
Add support for tagging camera images with a run_uuid, if supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
WillB97 committed Jul 11, 2024
1 parent 339384f commit 12ce826
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sbot/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,18 @@ def wrapped_publish(
"""Wrap a payload up to be decodable as JSON."""
if isinstance(payload, bytes):
payload = payload.decode('utf-8')

payload_dict = {
"timestamp": time.time(),
"data": payload,
}

if 'run_uuid' in os.environ:
payload_dict['run_uuid'] = os.environ['run_uuid']

self.publish(
topic,
json.dumps({
"timestamp": time.time(),
"data": payload,
}),
json.dumps(payload_dict),
retain=retain, abs_topic=abs_topic)

def _on_connect(
Expand Down

0 comments on commit 12ce826

Please sign in to comment.