adbus package

Submodules

adbus.datatypes module

class adbus.datatypes.VariantWrapper(value)[source]

Bases: object

Creates a D-Bus Variant from any value. For sending to D-Bus Interfaces.

dbus_signature = 'v'

adbus.exceptions module

D-Bus Exceptions from the adbus package

exception adbus.exceptions.BusError[source]

Bases: Exception

Error Interfacing on the D-Bus

Parameters:message – Error message

adbus.sdbus module

Interface to the systemd sd-bus library, not expected to be directly called by external applications.

class adbus.sdbus.Call

Bases: object

event
response
send()
class adbus.sdbus.Error

Bases: object

class adbus.sdbus.Listen

Bases: object

class adbus.sdbus.Manager

Bases: object

class adbus.sdbus.Message

Bases: object

class adbus.sdbus.Method

Bases: object

class adbus.sdbus.Object

Bases: object

emit_properties_changed()
class adbus.sdbus.Property

Bases: object

emit_changed()
exception adbus.sdbus.SdbusError

Bases: Exception

SD-Bus Library Configuration Error

class adbus.sdbus.Service

Bases: object

get_loop()

Get the service’s asyncio loop.

is_running()

Service is running.

process()

Processes all available transactions from the D-Bus.

Raises:
  • sdbus.BusError – if an error occurs interfacing with the D-Bus
  • Exception – re-raised if raised by any callbacks, or property setters
class adbus.sdbus.Signal

Bases: object

emit()
adbus.sdbus.camel_to_snake()

Converts CamelCase separated string to snake_case.

Parameters:camel (str) – CamelCase separated string
Returns:A string in snake_case.
adbus.sdbus.dbus_cast()

Casts an object into the type defined in a D-Bus signature.

Parameters:
  • signature (str) – D-Bus type signature
  • obj (object or type) – Python object or type
Returns:

A new type, cast from the D-Bus Signature.

adbus.sdbus.dbus_signature()

Calculates a D-Bus Signature from a Python object or type.

Parameters:obj (object or type) – Python object or type, If the object has a dbus_signature attribute it will be used, otherwise the object or type will be parsed to calculate the D-Bus Signature. Supports bool, int, str, float, bytes, and from the typing library, List, Dict, and Tuple.
Returns:A string representing the D-Bus Signature.
Raises:TypeError – If no D-Bus Equivalent for objects type.
adbus.sdbus.snake_to_camel()

Converts a snake_case string to CamelCase.

Parameters:snake (str) – Underscore separated string
Returns:A string in CamelCase.
adbus.sdbus.variant_signature()

adbus.service module

D-Bus Service

class adbus.service.Service(name=None, loop=None, bus='system', replace_existing=False, allow_replacement=False, name_queue=False)[source]

Bases: object

Serves objects onto a D-Bus, runs within an asyncio loop.

This is a class can be used to create a server that attaches the to D-Bus and either serves objects or provides and interface for a client proxy. To process requests it must be run within an asyncio loop.

Parameters:
  • name (str) – name to be used on the D-Bus, ie. org.test
  • loop – optional, asyncio loop to attach to, if not defined will use asyncio.get_event_loop()
  • bus (str) – optional, Bus to attach to either ‘system’, or ‘session’
  • replace_existing (bool) – optional, if true and there is a D-Bus service with the same name, try to replace it
  • allow_replacement (bool) – optional, if true and another service tries to steal our name, let it
  • name_queue (bool) – optional, if our name is in use by another service put ourselves in the D-Bus name queue, we will get name once the existing service relinquishes it
Raises:

BusError – if an error occurs during initialization

get_loop()[source]
is_running()[source]
sdbus = None

Interface to sd-bus library

Module contents