mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-20 22:43:45 +08:00
15 lines
380 B
Python
15 lines
380 B
Python
"""Keep native screen controls usable after a rejected or failed settings write."""
|
|
|
|
from collections.abc import Callable
|
|
|
|
from openpilot.common.params import UnknownKeyName
|
|
|
|
|
|
def try_screen_setting(write: Callable[[], object], on_error: Callable[[], None]) -> bool:
|
|
try:
|
|
write()
|
|
except (OSError, ValueError, UnknownKeyName):
|
|
on_error()
|
|
return False
|
|
return True
|