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:
@@ -41,8 +41,8 @@ class BusProvider(Thread):
|
||||
# ("Subdir2", Example()),
|
||||
# ("Subdir2/Whatever", Example())
|
||||
lst_interfaces = [
|
||||
InterfacePiControl(self.picontrol_device, self.config_rsc),
|
||||
InterfaceRevpiConfig(),
|
||||
InterfacePiControl(self._bus, self.picontrol_device, self.config_rsc),
|
||||
InterfaceRevpiConfig(self._bus),
|
||||
]
|
||||
|
||||
try:
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
"""Helper for dbus."""
|
||||
|
||||
from logging import getLogger
|
||||
from typing import Union
|
||||
|
||||
from pydbus import SessionBus, SystemBus
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
@@ -13,6 +15,9 @@ REVPI_DBUS_BASE_PATH = "/com/revolutionpi/middleware1"
|
||||
|
||||
class DbusInterface:
|
||||
|
||||
def __init__(self, bus: Union[SessionBus, SystemBus]):
|
||||
self.bus = bus
|
||||
|
||||
def cleanup(self):
|
||||
"""
|
||||
Represents a method responsible for performing cleanup operations. This method is executed to properly
|
||||
|
||||
@@ -26,7 +26,9 @@ class InterfacePiControl(DbusInterface):
|
||||
|
||||
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.config_rsc = config_rsc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user