mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-20 21:42:05 +08:00
events: fixup printing script (#30268)
* fix typing, no need for ordereddict, show priority name again * just repr
This commit is contained in:
@@ -970,10 +970,10 @@ EVENTS: Dict[int, Dict[str, Union[Alert, AlertCallbackType]]] = {
|
||||
if __name__ == '__main__':
|
||||
# print all alerts by type and priority
|
||||
from cereal.services import SERVICE_LIST
|
||||
from collections import defaultdict, OrderedDict
|
||||
from collections import defaultdict
|
||||
|
||||
event_names = {v: k for k, v in EventName.schema.enumerants.items()}
|
||||
alerts_by_type: Dict[str, Dict[int, List[str]]] = defaultdict(lambda: defaultdict(list))
|
||||
alerts_by_type: Dict[str, Dict[Priority, List[str]]] = defaultdict(lambda: defaultdict(list))
|
||||
|
||||
CP = car.CarParams.new_message()
|
||||
CS = car.CarState.new_message()
|
||||
@@ -983,18 +983,14 @@ if __name__ == '__main__':
|
||||
for et, alert in alerts.items():
|
||||
if callable(alert):
|
||||
alert = alert(CP, CS, sm, False, 1)
|
||||
priority = alert.priority
|
||||
alerts_by_type[et][priority].append(event_names[i])
|
||||
alerts_by_type[et][alert.priority].append(event_names[i])
|
||||
|
||||
all_alerts = {}
|
||||
all_alerts: Dict[str, List[tuple[Priority, List[str]]]] = {}
|
||||
for et, priority_alerts in alerts_by_type.items():
|
||||
all_alerts[et] = OrderedDict([
|
||||
(str(priority), l)
|
||||
for priority, l in sorted(priority_alerts.items(), key=lambda x: -int(x[0]))
|
||||
])
|
||||
all_alerts[et] = sorted(priority_alerts.items(), key=lambda x: x[0], reverse=True)
|
||||
|
||||
for status, evs in sorted(all_alerts.items(), key=lambda x: x[0]):
|
||||
print(f"**** {status} ****")
|
||||
for p, alert_list in evs.items():
|
||||
print(f" {p}:")
|
||||
for p, alert_list in evs:
|
||||
print(f" {repr(p)}:")
|
||||
print(" ", ', '.join(alert_list), "\n")
|
||||
|
||||
Reference in New Issue
Block a user