refactor: DBus interface includes bus instance

Updated `InterfaceRevpiConfig` to require a bus parameter, ensuring
proper initialization. Introduced a constructor in `DbusInterface` to
store the bus instance.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
This commit is contained in:
Sven Sager
2025-05-26 09:56:16 +02:00
parent a29979ad78
commit 32574e0815
3 changed files with 11 additions and 4 deletions

View File

@@ -41,8 +41,8 @@ class BusProvider(Thread):
# ("Subdir2", Example()), # ("Subdir2", Example()),
# ("Subdir2/Whatever", Example()) # ("Subdir2/Whatever", Example())
lst_interfaces = [ lst_interfaces = [
InterfacePiControl(self.picontrol_device, self.config_rsc), InterfacePiControl(self._bus, self.picontrol_device, self.config_rsc),
InterfaceRevpiConfig(), InterfaceRevpiConfig(self._bus),
] ]
try: try:

View File

@@ -2,8 +2,10 @@
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH # SPDX-FileCopyrightText: 2025 KUNBUS GmbH
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
"""Helper for dbus.""" """Helper for dbus."""
from logging import getLogger from logging import getLogger
from typing import Union
from pydbus import SessionBus, SystemBus
log = getLogger(__name__) log = getLogger(__name__)
@@ -13,6 +15,9 @@ REVPI_DBUS_BASE_PATH = "/com/revolutionpi/middleware1"
class DbusInterface: class DbusInterface:
def __init__(self, bus: Union[SessionBus, SystemBus]):
self.bus = bus
def cleanup(self): def cleanup(self):
""" """
Represents a method responsible for performing cleanup operations. This method is executed to properly Represents a method responsible for performing cleanup operations. This method is executed to properly

View File

@@ -26,7 +26,9 @@ class InterfacePiControl(DbusInterface):
NotifyDriverReset = signal() NotifyDriverReset = signal()
def __init__(self, picontrol_device: str, config_rsc: str): def __init__(self, bus, picontrol_device: str, config_rsc: str):
super().__init__(bus)
self.picontrol_device = picontrol_device self.picontrol_device = picontrol_device
self.config_rsc = config_rsc self.config_rsc = config_rsc