glib.ProxyInterface¶
- class dbus_fast.glib.ProxyInterface(bus_name: str, path: str, introspection: Interface, bus: BaseMessageBus)¶
Bases:
BaseProxyInterfaceA class representing a proxy to an interface exported on the bus by another client for the GLib
MessageBusimplementation.This class is not meant to be constructed directly by the user. Use
ProxyObject.get_interface()on a GLib proxy object to get a proxy interface.This class exposes methods to call DBus methods, listen to signals, and get and set properties on the interface that are created dynamically based on the introspection data passed to the proxy object that made this proxy interface.
A method call takes this form:
def callback(error: Exception, result: list(Any)): pass interface.call_[METHOD](*args, callback) result = interface.call_[METHOD]_sync(*args)
Where
METHODis the name of the method converted to snake case.To call a method, provide
*argsthat correspond to the in args of the introspection method definition.To asynchronously call a method, provide a callback that takes an error as the first argument and a list as the second argument. If the call completed successfully,
errorwill beNone. If the service returns an error, it will be aDBusErrorwith information about the error returned from the bus. The result will be a list of values that correspond to the out args of the introspection method definition.To synchronously call a method, use the
call_[METHOD]_sync()form. Theresultcorresponds to the out arg of the introspection method definition. If the method has more than one otu arg, they are returned within alist.To listen to a signal use this form:
interface.on_[SIGNAL](callback)
To stop listening to a signal use this form:
interface.off_[SIGNAL](callback)
Where
SIGNALis the name of the signal converted to snake case.DBus signals are exposed with an event-callback interface. The provided
callbackwill be called when the signal is emitted with arguments that correspond to the out args of the interface signal definition.To get or set a property use this form:
def get_callback(error: Exception, value: Any): pass def set_callback(error: Exception) pass interface.get_[PROPERTY](get_callback) value: Any = interface.get_[PROPERTY]_sync() interface.set_[PROPERTY](set_callback) interface.set_[PROPERTY]_sync(value)
Where
PROPERTYis the name of the property converted to snake case.The
valuemust correspond to the type of the property in the interface definition.To asynchronously get or set a property, provide a callback that takes an
Exceptionas the first argument. If the call completed successfully,errorwill beNone. If the service returns an error, it will be aDBusErrorwith information about the error returned from the bus.If the service returns an error for a synchronous DBus call, a
DBusErrorwill be raised with information about the error.