dasbus.server.interface module

accepts_additional_arguments(method)[source]

Decorator for accepting extra arguments in a DBus method.

The decorator allows the server object handler to propagate additional information about the DBus call into the decorated method.

Use a dictionary of keyword arguments:

@accepts_additional_arguments
def Method(x: Int, y: Str, **info):
    pass

Or use keyword only parameters:

@accepts_additional_arguments
def Method(x: Int, y: Str, *, call_info):
    pass

At this moment, the library provides only the call_info argument generated by GLibServer.get_call_info, but the additional arguments can be customized in the _get_additional_arguments method of the server object handler.

Parameters

method – a DBus method

Returns

a DBus method with a flag

are_additional_arguments_supported(method)[source]

Does the given DBus method accept additional arguments?

Parameters

method – a DBus method

Returns

True or False

dbus_class(cls)[source]

DBus class.

A new DBus class can be defined as:

@dbus_class
class Class(Interface):
    ...

DBus class can implement DBus interfaces, but it cannot define a new interface.

The DBus XML specification will be generated from implemented interfaces (inherited) and it will be accessible as:

Class.__dbus_xml__
dbus_interface(interface_name, namespace=())[source]

DBus interface.

A new DBus interface can be defined as:

@dbus_interface
class Interface():
    ...

The interface will be generated from the given class cls with a name interface_name and added to the DBus XML specification of the class.

The XML specification is accessible as: .. code-block:: python

Interface.__dbus_xml__

It is conventional for member names on DBus to consist of capitalized words with no punctuation. The generator of the XML specification enforces this convention to prevent unintended changes in the specification. You can provide the XML specification yourself, or override the generator class to work around these constraints.

Parameters
  • interface_name – a DBus name of the interface

  • namespace – a sequence of strings

class dbus_signal(definition=None, factory=<class 'dasbus.signal.Signal'>)[source]

Bases: object

DBus signal.

Can be used as:

Signal = dbus_signal()

Or as a method decorator:

@dbus_signal
def Signal(x: Int, y: Double):
    pass

Signal is defined by the type hints of a decorated method. This method is accessible as: signal.definition

If the signal is not defined by a method, it is expected to have no arguments and signal.definition is equal to None.

get_xml(obj)[source]

Return XML specification of an object.

Parameters

obj – an object decorated with @dbus_interface or @dbus_class

Returns

a string with XML specification