feat: Add session bus option for local testing and development

Introduced a `--use-session-bus` flag to optionally use the D-Bus
session bus instead of the system bus. This allows better flexibility
for local testing and development scenarios without requiring
system-level changes. Updated related classes and functions to respect
the new flag.
This commit is contained in:
2025-04-19 09:33:54 +02:00
parent a4ccb9081f
commit bde3920fc1
4 changed files with 19 additions and 7 deletions

View File

@@ -5,8 +5,9 @@ from threading import Thread
from time import sleep
from gi.repository import GLib
from pydbus import SystemBus
from pydbus import SessionBus, SystemBus
from .. import proginit as pi
from ..dbus_middleware1 import REVPI_DBUS_BASE_PATH
from ..dbus_middleware1 import REVPI_DBUS_NAME
@@ -34,7 +35,7 @@ def simple_call(method: str, *args, interface: str, object_path=REVPI_DBUS_BASE_
Any
The result of the method invocation on the targeted D-Bus interface.
"""
bus = SystemBus()
bus = SessionBus() if pi.pargs.use_session_bus else SystemBus()
revpi = bus.get(REVPI_DBUS_NAME, object_path)
iface = revpi[interface]
return getattr(iface, method)(*args)
@@ -55,7 +56,7 @@ def await_signal(signal_name: str, timeout: int, interface: str, object_path=REV
detected_signal = True
loop.quit()
bus = SystemBus()
bus = SessionBus() if pi.pargs.use_session_bus else SystemBus()
revpi = bus.get(REVPI_DBUS_NAME, object_path)
iface = revpi[interface]