Package dbus :: Module proxies :: Class ProxyObject
[hide private]
[frames] | no frames]

Class ProxyObject

source code

object --+
         |
        ProxyObject

A proxy to the remote Object.

A ProxyObject is provided by the Bus. ProxyObjects have member functions, and can be called like normal Python objects.

Nested Classes [hide private]
  ProxyMethodClass
A proxy method.
  DeferredMethodClass
A proxy method which will only get called once we have its introspection reply.
Instance Methods [hide private]
 
__init__(self, conn=None, bus_name=None, object_path=None, introspect=True, follow_name_owner_changes=False, **kwargs)
Initialize the proxy object.
source code
 
connect_to_signal(self, signal_name, handler_function, dbus_interface=None, **keywords)
Arrange for the given function to be called when the given signal is received.
source code
 
_Introspect(self) source code
 
_introspect_execute_queue(self) source code
 
_introspect_reply_handler(self, data) source code
 
_introspect_error_handler(self, error) source code
 
_introspect_block(self) source code
 
_introspect_add_to_queue(self, callback, args, kwargs) source code
 
__getattr__(self, member) source code
 
get_dbus_method(self, member, dbus_interface=None)
Return a proxy method representing the given D-Bus method. The returned proxy method can be called in the usual way. For instance,
source code
 
__repr__(self)
str(x)
source code
 
__str__(self)
str(x)
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Class Variables [hide private]
  INTROSPECT_STATE_DONT_INTROSPECT = 0
  INTROSPECT_STATE_INTROSPECT_IN_PROGRESS = 1
  INTROSPECT_STATE_INTROSPECT_DONE = 2
Properties [hide private]
  bus_name
The bus name to which this proxy is bound. (Read-only, may change.)
  requested_bus_name
The bus name which was requested when this proxy was instantiated.
  object_path
The object-path of this proxy.

Inherited from object: __class__

Method Details [hide private]

__init__(self, conn=None, bus_name=None, object_path=None, introspect=True, follow_name_owner_changes=False, **kwargs)
(Constructor)

source code 
Initialize the proxy object.
Parameters:
  • conn (dbus.connection.Connection) - The bus or connection on which to find this object. The keyword argument bus is a deprecated alias for this.
  • bus_name (str) - A bus name for the application owning the object, to be used as the destination for method calls and the sender for signal matches. The keyword argument named_service is a deprecated alias for this.
  • object_path (str) - The object path at which the application exports the object
  • introspect (bool) - If true (default), attempt to introspect the remote object to find out supported methods and their signatures
  • follow_name_owner_changes (bool) - If true (default is false) and the bus_name is a well-known name, follow ownership changes for that name
Overrides: object.__init__

connect_to_signal(self, signal_name, handler_function, dbus_interface=None, **keywords)

source code 
Arrange for the given function to be called when the given signal is received.
Parameters:
  • signal_name (str) - The name of the signal
  • handler_function (callable) - A function to be called when the signal is emitted by the remote object. Its positional arguments will be the arguments of the signal; optionally, it may be given keyword arguments as described below.
  • dbus_interface (str) - Optional interface with which to qualify the signal name. If None (the default) the handler will be called whenever a signal of the given member name is received, whatever its interface.
  • utf8_strings (bool) - If True, the handler function will receive any string arguments as dbus.UTF8String objects (a subclass of str guaranteed to be UTF-8). If False (default) it will receive any string arguments as dbus.String objects (a subclass of unicode).
  • byte_arrays (bool) - If True, the handler function will receive any byte-array arguments as dbus.ByteArray objects (a subclass of str). If False (default) it will receive any byte-array arguments as a dbus.Array of dbus.Byte (subclasses of: a list of ints).
  • sender_keyword (str) - If not None (the default), the handler function will receive the unique name of the sending endpoint as a keyword argument with this name
  • destination_keyword (str) - If not None (the default), the handler function will receive the bus name of the destination (or None if the signal is a broadcast, as is usual) as a keyword argument with this name.
  • interface_keyword (str) - If not None (the default), the handler function will receive the signal interface as a keyword argument with this name.
  • member_keyword (str) - If not None (the default), the handler function will receive the signal name as a keyword argument with this name.
  • path_keyword (str) - If not None (the default), the handler function will receive the object-path of the sending object as a keyword argument with this name
  • message_keyword (str) - If not None (the default), the handler function will receive the dbus.lowlevel.SignalMessage as a keyword argument with this name.
  • arg... (unicode or UTF-8 str) - If there are additional keyword parameters of the form argn, match only signals where the nth argument is the value given for that keyword parameter. As of this time only string arguments can be matched (in particular, object paths and signatures can't).

get_dbus_method(self, member, dbus_interface=None)

source code 

Return a proxy method representing the given D-Bus method. The returned proxy method can be called in the usual way. For instance,

proxy.get_dbus_method("Foo", dbus_interface='com.example.Bar')(123)

is equivalent to:

proxy.Foo(123, dbus_interface='com.example.Bar')

or even:

getattr(proxy, "Foo")(123, dbus_interface='com.example.Bar')

However, using get_dbus_method is the only way to call D-Bus methods with certain awkward names - if the author of a service implements a method called connect_to_signal or even __getattr__, you'll need to use get_dbus_method to call them.

For services which follow the D-Bus convention of CamelCaseMethodNames this won't be a problem.

__repr__(self)
(Representation operator)

source code 
str(x)
Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 
str(x)
Overrides: object.__str__
(inherited documentation)

Property Details [hide private]

bus_name

The bus name to which this proxy is bound. (Read-only, may change.)

If the proxy was instantiated using a unique name, this property is that unique name.

If the proxy was instantiated with a well-known name and with follow_name_owner_changes set false (the default), this property is the unique name of the connection that owned that well-known name when the proxy was instantiated, which might not actually own the requested well-known name any more.

If the proxy was instantiated with a well-known name and with follow_name_owner_changes set true, this property is that well-known name.

Get Method:
unreachable(self)

requested_bus_name

The bus name which was requested when this proxy was instantiated.
Get Method:
unreachable(self)

object_path

The object-path of this proxy.
Get Method:
unreachable(self)