adbus.server package¶
Submodules¶
adbus.server.method module¶
D-Bus Method
-
class
adbus.server.method.
Method
(callback, name=None, depreciated=False, hidden=False, unprivileged=False, camel_convert=True, dont_block=False, threadsafe=True)[source]¶ Bases:
object
Provides an interface between a D-Bus and a Python Method or Function.
Though this class can be used on its own it is intended to be used with the method decorator applied to methods on a class that is a subclass of the main Object type.
Parameters: - callback (function) – function that will be called when D-Bus method is called, it should use new style type annotations to define the types of all arguments, and the return value, ie. function(x: int, y: str) -> bool: if no type is defined a D-Bus Variant will be used
- name (str) – optional, name of the method advertised on the D-Bus if not set then will use the callback name
- depreciated (bool) – optional, if true object is labelled as depreciated in the introspect XML data
- hidden (bool) – optional, if true object won’t be added to the introspect XML data
- unprivileged (bool) – optional, indicates that this method may have to ask the user for authentication before executing, which may take a little while
- camel_convert (bool) – optional, D-Bus method and property names are typically defined in Camel Case, but Python methods and arguments are typically defined in Snake Case, if this is set the cases will be automatically converted between the two
- dont_block (bool) – optional, if true the method call will not block on the D-Bus, a value will never be returned
- threadsafe (bool) – optional, if the method isn’t threadsafe (False) the object will lock, so that only one of the objects non-threadsafe methods can run at a time, default is True NOTE: this will only work if this is decorating a class method, as the lock has to be connected to the method
Raises: BusError
– if an error occurs during initialization-
callback
= None¶ Function called when this method is called.
-
dbus_name
= None¶ Method name advertised on the D-Bus.
-
adbus.server.method.
method
(name=None, depreciated=False, hidden=False, unprivileged=False, camel_convert=True, dont_block=False, threadsafe=True)[source]¶ D-Bus Method Decorator.
Note
The decorated method should use new style type annotations to define the types of all arguments, and the return value, ie function(x: int, y: str) -> bool: if no type is defined a D-Bus Variant will be used
Parameters: - name (str) – optional, if set this name will be used on the D-Bus, instead of the decorated function’s name
- depreciated (bool) – optional, if true object is labelled as depreciated in the introspect XML data
- hidden (bool) – optional, if true object won’t be added to the introspect XML data
- unprivileged (bool) – optional, indicates that this method may have to ask the user for authentication before executing, which may take a little while
- camel_convert (bool) – optional, D-Bus method and property names are typically defined in Camel Case, but Python methods and arguments are typically defined in Snake Case, if this is set the cases will be automatically converted between the two
- dont_block (bool) – optional, if true the method call will not block on the D-Bus, a value will never be returned
- threadsafe (bool) – optional, if the method isn’t threadsafe (False) the object will lock, so that only one of the objects non-threadsafe methods can run at a time, default is True NOTE: this will only work if this is decorating a class method, as the lock has to be connected to the method
Returns: Instantiated Method, which can be used to replace a method or function.
adbus.server.object module¶
D-Bus Object
-
class
adbus.server.object.
Object
(service, path, interface, vtable=(), depreciated=False, hidden=False, manager=False)[source]¶ Bases:
object
Provides an interface between a D-Bus and a Python Object.
Though this class can be used on its own it is intended to be inherited by another object which uses decorators to define methods, properties, and signals which are exposed on the D-Bus.
This object must be added to a service, which provides the D-Bus interface.
It also provides a Context Manager so that multiple properties can be set, or one property can be set multiple times, with a single D-Bus changed signal being sent for all property updates once the context is closed.
Parameters: - service (adbus.server.Service) – service to connect to
- path (str) – path to create on the service ie. /com/awesome/Settings
- interface (str) – interface label to use for all of this objects methods and properties, ie. com.awesome.settings
- vtable (list) – optional, list of signals, methods, and properties that will be added to the D-Bus Object, this list is in addition to the methods, properties, and signals which are added to this object using the provided decorators and descriptors
- depreciated (bool) – optional, if true object is labelled as depreciated in the introspect XML data
- hidden (bool) – optional, if true object won’t be added to the introspect XML data
- manager (bool) – optional, if True add a device manager to this object, as defined by the D-Bus Spec from freedesktop.org
Raises: BusError
– if an error occurs during initialization
adbus.server.property module¶
D-Bus Property
-
class
adbus.server.property.
Property
(default=None, name=None, read_only=False, constant=False, depreciated=False, hidden=False, unprivileged=False, emits_change=True, emits_invalidation=False, camel_convert=True)[source]¶ Bases:
object
Provides an interface between a D-Bus and a Python Property.
This class is to be used as a Decorator for arguments (properties) in an adbus.server.Object which will be exported via the D-Bus.
Parameters: - default – optional, default setting for the property
- name (str) – optional, property name used in the D-Bus, if None the property’s label will be used
- read_only (bool) – if True the property can only be read via D-Bus (but can still be set locally)
- constant (bool) – if True the property can only be read via D-Bus or locally, it also advertises constant in the introspect XML data
- depreciated (bool) – optional, if true object is labelled as depreciated in the introspect XML data
- hidden (bool) – optional, if true object won’t be added to the introspect XML data
- unprivileged (bool) – optional, indicates that this method may have to ask the user for authentication before executing, which may take a little while
- emits_change (bool) – optional, when changed emits a signal with the new value
- emits_invalidation (bool) – optional, when changed emits a signal but doesn’t provide the new value, can be used for large, complex properties, overrides emits_change if it’s set
- camel_convert (bool) – optional, D-Bus method and property names are typically defined in Camel Case, but Python methods and arguments are typically defined in Snake Case, if this is set the cases will be automatically converted between the two
adbus.server.signal module¶
D-Bus Signal
-
class
adbus.server.signal.
Signal
(name=None, deprectiated=False, hidden=False, camel_convert=True)[source]¶ Bases:
object
Provides a method to emit a signal via D-Bus.
This class is to be used as a Decorator for signals in an adbus.server.Object which will be exported via the D-Bus.
Parameters: - name (str) – optional, signal name used in the D-Bus, if None the signal’s label will be used
- depreciated (bool) – optional, if true object is labelled as depreciated in the introspect XML data
- hidden (bool) – optional, if true object won’t be added to the introspect XML data
- camel_convert (bool) – optional, D-Bus method and property names are typically defined in Camel Case, but Python methods and arguments are typically defined in Snake Case, if this is set the cases will be automatically converted between the two