refactor(dbus): D-Bus interface management with cleanup support.

Introduced a `DbusInterface` base class with a `cleanup` method to
standardize resource cleanup for D-Bus interfaces. Modified
`InterfacePiControl` to inherit from it and implemented `cleanup` logic
for proper watchdog resource handling. Adjusted `BusProvider` to manage
multiple interfaces and ensure cleanup on shutdown.
This commit is contained in:
2025-04-19 15:55:49 +02:00
parent f8bc1532e3
commit 26c3ac0afb
3 changed files with 33 additions and 2 deletions

View File

@@ -11,6 +11,18 @@ REVPI_DBUS_NAME = "com.revolutionpi.middleware1"
REVPI_DBUS_BASE_PATH = "/com/revolutionpi/middleware1"
class DbusInterface:
def cleanup(self):
"""
Represents a method responsible for performing cleanup operations. This method is executed to properly
release resources, close connections, or perform other necessary finalization tasks.
This method does not take any arguments or return a value.
"""
pass
def extend_interface(*args) -> str:
"""
Extends an interface name by appending additional segments to a pre-defined base name.