crystalfontz.dbus.service

Functions for creating and serving a DBus service.

Typically, the DBus service will be executed through the CLI interface, for instance with:

python3 -m crystalfontz.dbus.service

However, these functions may be useful if you want to embed the DBus service within another program.

serve(config_file=None) async

Create and serve configure DBus service with a supplied config file.

Source code in crystalfontz/dbus/service/__init__.py
56
57
58
59
60
61
62
63
64
async def serve(config_file: Optional[str] = None) -> None:
    """
    Create and serve configure DBus service with a supplied config file.
    """

    async with handle_dbus_error(logger):
        srv = await service(config_file)

        await srv.closed

service(config_file=None) async

Create a configure DBus service with a supplied config file.

Source code in crystalfontz/dbus/service/__init__.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
async def service(config_file: Optional[str] = None) -> DbusInterface:
    """
    Create a configure DBus service with a supplied config file.
    """

    report_handler = DbusInterfaceReportHandler()
    client = await load_client(report_handler=report_handler, config_file=config_file)
    iface = DbusInterface(
        client, report_handler=report_handler, config_file=config_file
    )

    logger.debug(f"Requesting bus name {DBUS_NAME}...")
    await request_default_bus_name_async(DBUS_NAME)

    logger.debug("Exporting interface to path /...")

    iface.export_to_dbus("/")

    logger.info(f"Listening on {DBUS_NAME} /")

    return iface