Compare commits

..

2 Commits

Author SHA1 Message Date
121bd007b3 [P] Add container logs printout on crash
Some checks failed
Component testing / Hub testing (push) Successful in 24s
Component testing / Store testing (push) Successful in 27s
Component testing / Integration smoke testing (push) Has been cancelled
2026-03-25 22:56:12 +02:00
db63eb6d79 [P] Improve logging logic in agent
All checks were successful
Component testing / Hub testing (push) Successful in 24s
Component testing / Store testing (push) Successful in 27s
Component testing / Integration smoke testing (push) Successful in 2m25s
2026-03-25 15:40:07 +02:00
3 changed files with 18 additions and 34 deletions

View File

@@ -14,24 +14,11 @@ line_layer_colors = [
[1, 0, 1, 1],
]
def get_lat_lon(point: dict[str, float] | list[float] | tuple[float, float]) -> tuple[float, float] | None:
if isinstance(point, dict):
lat = point.get("lat")
lon = point.get("lon")
else:
lat, lon = point
if lat is None or lon is None:
return None
return lat, lon
class MapViewApp(App):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.mapview: MapView | None = None
self.mapview = None
self.datasource = Datasource(user_id=1)
self.line_layers = dict()
self.car_markers = dict()
@@ -123,34 +110,24 @@ class MapViewApp(App):
self.pothole_markers.append(marker)
def set_bump_marker(self, point):
lat, lon = get_lat_lon(point)
if isinstance(point, dict):
lat = point.get("lat")
lon = point.get("lon")
else:
lat, lon = point
if lat is None or lon is None:
return
marker = MapMarker(
lat=lat,
lon=lon,
source="images/bump.png"
source="images/bump.png"
)
self.mapview.add_marker(marker)
self.bump_markers.append(marker)
def delete_bump_marker(self, point):
lat, lon = get_lat_lon(point)
if lat is None or lon is None:
return
marker = MapMarker(
lat=lat,
lon=lon,
source="images/bump.png"
)
if marker in self.bump_markers:
self.mapview.remove_marker(marker)
self.bump_markers.pop(self.bump_markers.index(marker))
def build(self):
"""

View File

@@ -16,6 +16,8 @@ def connect_mqtt(broker, port):
print("Failed to connect {broker}:{port}, return code %d\n", rc)
exit(rc) # Stop execution
logging.info(f"Acting as USER_ID = {config.USER_ID}")
client = mqtt_client.Client()
client.on_connect = on_connect
client.connect(broker, port)
@@ -29,13 +31,14 @@ def publish(client, topic, datasource):
data = datasource.read()
msg = AggregatedDataSchema().dumps(data)
result = client.publish(topic, msg)
logging.info(f"Published to {topic}: {msg[:50]}...")
logging.debug(f"Published to {topic}: {msg[:50]}...")
status = result[0]
if status != 0:
print(f"Failed to send message to topic {topic}")
logging.error(f"Failed to send message to topic {topic}")
def run():
logging.basicConfig(level = logging.INFO)
# Prepare mqtt client
client = connect_mqtt(config.MQTT_BROKER_HOST, config.MQTT_BROKER_PORT)
# Prepare datasource

View File

@@ -1,4 +1,5 @@
import sys
import os
print("Checking for dead containers...")
@@ -14,6 +15,9 @@ for i in statuses:
if not i[status_index:].startswith("Up "):
service_name = i[name_index:]
print(f"Crash detected in {service_name}")
print(f"docker logs for the container:\n")
os.system(f"docker logs {i.split(' ')[0]}")
print()
exit_code = 1
sys.exit(exit_code)