Package dbus :: Module connection :: Class Connection
[hide private]
[frames] | no frames]

Class Connection

source code

               object --+    
                        |    
_dbus_bindings.Connection --+
                            |
                           Connection
Known Subclasses:

A connection to another application. In this base class there is assumed to be no bus daemon.

Since: 0.81.0

Nested Classes [hide private]
  ProxyObjectClass
A proxy to the remote Object.
Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
activate_name_owner(self, bus_name)
Return the unique name for the given bus name, activating it if necessary and possible.
source code
 
get_object(self, bus_name=None, object_path=None, introspect=True, **kwargs)
Return a local proxy for the given remote object.
source code
 
add_signal_receiver(self, handler_function, signal_name=None, dbus_interface=None, bus_name=None, path=None, **keywords)
Arrange for the given function to be called when a signal matching the parameters is received.
source code
 
_iter_easy_matches(self, path, dbus_interface, member) source code
 
remove_signal_receiver(self, handler_or_match, signal_name=None, dbus_interface=None, bus_name=None, path=None, **keywords) source code
 
_clean_up_signal_match(self, match) source code
 
_signal_func(self, message)
D-Bus filter function.
source code
 
call_async(self, bus_name, object_path, dbus_interface, method, signature, args, reply_handler, error_handler, timeout=-1.0, utf8_strings=False, byte_arrays=False, require_main_loop=True)
Call the given method, asynchronously.
source code
 
call_blocking(self, bus_name, object_path, dbus_interface, method, signature, args, timeout=-1.0, utf8_strings=False, byte_arrays=False)
Call the given method, synchronously.
source code
 
call_on_disconnection(self, callable)
Arrange for callable to be called with one argument (this Connection object) when the Connection becomes disconnected.
source code

Inherited from _dbus_bindings.Connection: __new__, add_message_filter, close, flush, get_is_authenticated, get_is_connected, get_peer_unix_process_id, get_peer_unix_user, get_unique_name, get_unix_fd, list_exported_child_objects, remove_message_filter, send_message, send_message_with_reply, send_message_with_reply_and_block, set_exit_on_disconnect, set_unique_name

Inherited from _dbus_bindings.Connection (private): _new_for_bus, _register_object_path, _require_main_loop, _unregister_object_path

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
  _signal_recipients_by_object_path
Map from object path to dict mapping dbus_interface to dict mapping member to list of SignalMatch objects.
  _signals_lock
Lock used to protect signal data structures
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

activate_name_owner(self, bus_name)

source code 

Return the unique name for the given bus name, activating it if necessary and possible.

If the name is already unique or this connection is not to a bus daemon, just return it.

Returns:
a bus name. If the given bus_name exists, the returned name identifies its current owner; otherwise the returned name does not exist.
Raises:
  • DBusException - if the implementation has failed to activate the given bus name.

Since: 0.81.0

get_object(self, bus_name=None, object_path=None, introspect=True, **kwargs)

source code 

Return a local proxy for the given remote object.

Method calls on the proxy are translated into method calls on the remote object.

Parameters:
  • bus_name (str) - A bus name (either the unique name or a well-known name) of the application owning the object. The keyword argument named_service is a deprecated alias for this.
  • object_path (str) - The object path of the desired object
  • introspect (bool) - If true (default), attempt to introspect the remote object to find out supported methods and their signatures
Returns:
a dbus.proxies.ProxyObject

add_signal_receiver(self, handler_function, signal_name=None, dbus_interface=None, bus_name=None, path=None, **keywords)

source code 
Arrange for the given function to be called when a signal matching the parameters is received.
Parameters:
  • handler_function (callable) - The function to be called. Its positional arguments will be the arguments of the signal. By default it will receive no keyword arguments, but see the description of the optional keyword arguments below.
  • signal_name (str) - The signal name; None (the default) matches all names
  • dbus_interface (str) - The D-Bus interface name with which to qualify the signal; None (the default) matches all interface names
  • bus_name (str) - A bus name for the sender, which will be resolved to a unique name if it is not already; None (the default) matches any sender.
  • path (str) - The object path of the object which must have emitted the signal; None (the default) matches any object path
  • 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).
  • named_service (str) - A deprecated alias for bus_name.

_signal_func(self, message)

source code 
D-Bus filter function. Handle signals by dispatching to Python callbacks kept in the match-rule tree.

call_async(self, bus_name, object_path, dbus_interface, method, signature, args, reply_handler, error_handler, timeout=-1.0, utf8_strings=False, byte_arrays=False, require_main_loop=True)

source code 

Call the given method, asynchronously.

If the reply_handler is None, successful replies will be ignored. If the error_handler is None, failures will be ignored. If both are None, the implementation may request that no reply is sent.

Returns:
The dbus.lowlevel.PendingCall.

Since: 0.81.0

call_blocking(self, bus_name, object_path, dbus_interface, method, signature, args, timeout=-1.0, utf8_strings=False, byte_arrays=False)

source code 
Call the given method, synchronously. :Since: 0.81.0

call_on_disconnection(self, callable)

source code 
Arrange for callable to be called with one argument (this Connection object) when the Connection becomes disconnected.

Since: 0.83.0