Package dbus :: Module bus :: Class BusConnection
[hide private]
[frames] | no frames]

Class BusConnection

source code

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

A connection to a D-Bus daemon that implements the org.freedesktop.DBus pseudo-service.

Since: 0.81.0

Nested Classes [hide private]

Inherited from connection.Connection: ProxyObjectClass

Instance Methods [hide private]
 
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
 
_clean_up_signal_match(self, match) 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, object_path, introspect=True, follow_name_owner_changes=False, **kwargs)
Return a local proxy for the given remote object.
source code
 
get_unix_user(self, bus_name)
Get the numeric uid of the process owning the given bus name.
source code
 
start_service_by_name(self, bus_name, flags=0)
Start a service which will implement the given bus name on this Bus.
source code
 
request_name(self, name, flags=0)
Request a bus name.
source code
 
release_name(self, name)
Release a bus name.
source code
 
list_names(self)
Return a list of all currently-owned names on the bus.
source code
 
list_activatable_names(self)
Return a list of all names that can be activated on the bus.
source code
 
get_name_owner(self, bus_name)
Return the unique connection name of the primary owner of the given name.
source code
 
watch_name_owner(self, bus_name, callback)
Watch the unique connection name of the primary owner of the given name.
source code
 
name_has_owner(self, bus_name)
Return True iff the given bus name has an owner on this bus.
source code
 
add_match_string(self, rule)
Arrange for this application to receive messages on the bus that match the given rule. This version will block.
source code
 
add_match_string_non_blocking(self, rule)
Arrange for this application to receive messages on the bus that match the given rule. This version will not block, but any errors will be ignored.
source code
 
remove_match_string(self, rule)
Arrange for this application to receive messages on the bus that match the given rule. This version will block.
source code
 
remove_match_string_non_blocking(self, rule)
Arrange for this application to receive messages on the bus that match the given rule. This version will not block, but any errors will be ignored.
source code

Inherited from connection.Connection: __init__, call_async, call_blocking, call_on_disconnection, remove_signal_receiver

Inherited from _dbus_bindings.Connection: 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_allow_anonymous, 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__

Static Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, address_or_type=0, mainloop=None) source code
Class Variables [hide private]
  TYPE_SESSION = 0
Represents a session bus (same as the global dbus.BUS_SESSION)
  TYPE_SYSTEM = 1
Represents the system bus (same as the global dbus.BUS_SYSTEM)
  TYPE_STARTER = 2
Represents the bus that started this service by activation (same as the global dbus.BUS_STARTER)
  START_REPLY_SUCCESS = 1
  START_REPLY_ALREADY_RUNNING = 2
Instance Variables [hide private]
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(cls, address_or_type=0, mainloop=None)
Static Method

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

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 - 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 - The signal name; None (the default) matches all names
  • dbus_interface - The D-Bus interface name with which to qualify the signal; None (the default) matches all interface names
  • bus_name - 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 - The object path of the object which must have emitted the signal; None (the default) matches any object path
  • utf8_strings - 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 - 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 - 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 - 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 - If not None (the default), the handler function will receive the signal interface as a keyword argument with this name.
  • member_keyword - If not None (the default), the handler function will receive the signal name as a keyword argument with this name.
  • path_keyword - 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 - If not None (the default), the handler function will receive the dbus.lowlevel.SignalMessage as a keyword argument with this name.
  • arg... - 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 - A deprecated alias for bus_name.
Overrides: connection.Connection.add_signal_receiver
(inherited documentation)

_clean_up_signal_match(self, match)

source code 
Overrides: connection.Connection._clean_up_signal_match

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.
Overrides: connection.Connection.activate_name_owner
(inherited documentation)

get_object(self, bus_name, object_path, introspect=True, follow_name_owner_changes=False, **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
  • follow_name_owner_changes (bool) - If the object path is a well-known name and this parameter is false (default), resolve the well-known name to the unique name of its current owner and bind to that instead; if the ownership of the well-known name changes in future, keep communicating with the original owner. This is necessary if the D-Bus API used is stateful.

    If the object path is a well-known name and this parameter is true, whenever the well-known name changes ownership in future, bind to the new owner, if any.

    If the given object path is a unique name, this parameter has no effect.

Returns:
a dbus.proxies.ProxyObject
Raises:
  • DBusException - if resolving the well-known name to a unique name fails
Overrides: connection.Connection.get_object

get_unix_user(self, bus_name)

source code 
Get the numeric uid of the process owning the given bus name.
Parameters:
  • bus_name (str) - A bus name, either unique or well-known
Returns:
a dbus.UInt32

Since: 0.80.0

start_service_by_name(self, bus_name, flags=0)

source code 
Start a service which will implement the given bus name on this Bus.
Parameters:
  • bus_name (str) - The well-known bus name to be activated.
  • flags (dbus.UInt32) - Flags to pass to StartServiceByName (currently none are defined)
Returns:
A tuple of 2 elements. The first is always True, the second is either START_REPLY_SUCCESS or START_REPLY_ALREADY_RUNNING.
Raises:

Since: 0.80.0

request_name(self, name, flags=0)

source code 
Request a bus name.
Parameters:
  • name (str) - The well-known name to be requested
  • flags (dbus.UInt32) - A bitwise-OR of 0 or more of the flags NAME_FLAG_ALLOW_REPLACEMENT, NAME_FLAG_REPLACE_EXISTING and NAME_FLAG_DO_NOT_QUEUE
Returns:
REQUEST_NAME_REPLY_PRIMARY_OWNER, REQUEST_NAME_REPLY_IN_QUEUE, REQUEST_NAME_REPLY_EXISTS or REQUEST_NAME_REPLY_ALREADY_OWNER
Raises:
  • DBusException - if the bus daemon cannot be contacted or returns an error.

release_name(self, name)

source code 
Release a bus name.
Parameters:
  • name (str) - The well-known name to be released
Returns:
RELEASE_NAME_REPLY_RELEASED, RELEASE_NAME_REPLY_NON_EXISTENT or RELEASE_NAME_REPLY_NOT_OWNER
Raises:
  • DBusException - if the bus daemon cannot be contacted or returns an error.

list_names(self)

source code 
Return a list of all currently-owned names on the bus.
Returns:
a dbus.Array of dbus.UTF8String

Since: 0.81.0

list_activatable_names(self)

source code 
Return a list of all names that can be activated on the bus.
Returns:
a dbus.Array of dbus.UTF8String

Since: 0.81.0

get_name_owner(self, bus_name)

source code 
Return the unique connection name of the primary owner of the given name.
Raises:

Since: 0.81.0

watch_name_owner(self, bus_name, callback)

source code 

Watch the unique connection name of the primary owner of the given name.

callback will be called with one argument, which is either the unique connection name, or the empty string (meaning the name is not owned).

Since: 0.81.0

name_has_owner(self, bus_name)

source code 
Return True iff the given bus name has an owner on this bus.
Parameters:
  • bus_name (str) - The bus name to look up
Returns:
a bool

add_match_string(self, rule)

source code 
Arrange for this application to receive messages on the bus that match the given rule. This version will block.
Parameters:
  • rule (str) - The match rule
Raises:

Since: 0.80.0

add_match_string_non_blocking(self, rule)

source code 
Arrange for this application to receive messages on the bus that match the given rule. This version will not block, but any errors will be ignored.
Parameters:
  • rule (str) - The match rule
Raises:

Since: 0.80.0

remove_match_string(self, rule)

source code 
Arrange for this application to receive messages on the bus that match the given rule. This version will block.
Parameters:
  • rule (str) - The match rule
Raises:

Since: 0.80.0

remove_match_string_non_blocking(self, rule)

source code 
Arrange for this application to receive messages on the bus that match the given rule. This version will not block, but any errors will be ignored.
Parameters:
  • rule (str) - The match rule
Raises:

Since: 0.80.0