feat(dbus): Add initial D-Bus middleware implementation
Introduce a D-Bus middleware module for revpi_middleware, including an interface definition and a `BusProvider` class to handle D-Bus communication. This forms the foundation for middleware interactions using D-Bus.
This commit is contained in:
8
src/revpi_middleware/dbus_middleware1/__init__.py
Normal file
8
src/revpi_middleware/dbus_middleware1/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
"""D-Bus middleware version 1 of revpi_middleware."""
|
||||
from ..__about__ import __author__, __copyright__, __license__, __version__
|
||||
|
||||
REVPI_DBUS_NAME = "com.revolutionpi.middleware1"
|
||||
REVPI_DBUS_BASE_PATH = "/com/revolutionpi/middleware1"
|
||||
40
src/revpi_middleware/dbus_middleware1/bus_provider.py
Normal file
40
src/revpi_middleware/dbus_middleware1/bus_provider.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
"""D-Bus bus provider for revpi_middleware."""
|
||||
from logging import getLogger
|
||||
from threading import Thread
|
||||
|
||||
from gi.repository import GLib
|
||||
from pydbus import SystemBus
|
||||
|
||||
from . import REVPI_DBUS_NAME
|
||||
from .process_image import InterfacePiControl
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
|
||||
class BusProvider(Thread):
|
||||
|
||||
def __init__(self):
|
||||
log.debug("enter BusProvider.__init__")
|
||||
super().__init__()
|
||||
|
||||
self._bus = SystemBus()
|
||||
self._loop = GLib.MainLoop()
|
||||
|
||||
def run(self):
|
||||
log.debug("enter BusProvider.run")
|
||||
|
||||
self._bus.publish(
|
||||
REVPI_DBUS_NAME,
|
||||
InterfacePiControl(),
|
||||
)
|
||||
|
||||
self._loop.run()
|
||||
log.debug("leave BusProvider.run")
|
||||
|
||||
def stop(self):
|
||||
log.debug("enter BusProvider.stop")
|
||||
self._loop.quit()
|
||||
log.debug("leave BusProvider.stop")
|
||||
Reference in New Issue
Block a user