dbus.bus module¶
-
class
dbus.bus.
BusConnection
(*args, **kwargs)¶ Bases:
dbus.connection.Connection
A connection to a D-Bus daemon that implements the
org.freedesktop.DBus
pseudo-service.Since: 0.81.0 -
START_REPLY_ALREADY_RUNNING
= 2¶
-
START_REPLY_SUCCESS
= 1¶
-
TYPE_SESSION
= 0¶ Represents a session bus (same as the global dbus.BUS_SESSION)
-
TYPE_STARTER
= 2¶ Represents the bus that started this service by activation (same as the global dbus.BUS_STARTER)
-
TYPE_SYSTEM
= 1¶ Represents the system bus (same as the global dbus.BUS_SYSTEM)
-
activate_name_owner
(bus_name)¶
-
add_match_string
(rule)¶ 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 DBusExceptionDBusException: on error.
Since: 0.80.0
-
add_match_string_non_blocking
(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.
Parameters: - rule : str
The match rule
Raises DBusExceptionDBusException: on error.
Since: 0.80.0
-
add_signal_receiver
(handler_function, signal_name=None, dbus_interface=None, bus_name=None, path=None, **keywords)¶
-
get_name_owner
(bus_name)¶ Return the unique connection name of the primary owner of the given name.
Raises DBusExceptionDBusException: if the bus_name has no owner Since: 0.81.0
-
get_object
(bus_name, object_path, introspect=True, follow_name_owner_changes=False, **kwargs)¶ 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 DBusExceptionDBusException: if resolving the well-known name to a unique name fails
-
get_unix_user
(bus_name)¶ 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
-
list_activatable_names
()¶ Return a list of all names that can be activated on the bus.
Returns: a dbus.Array of dbus.UTF8String Since: 0.81.0
-
list_names
()¶ Return a list of all currently-owned names on the bus.
Returns: a dbus.Array of dbus.UTF8String Since: 0.81.0
-
name_has_owner
(bus_name)¶ 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
-
release_name
(name)¶ 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 DBusExceptionDBusException: if the bus daemon cannot be contacted or returns an error.
-
remove_match_string
(rule)¶ 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 DBusExceptionDBusException: on error.
Since: 0.80.0
-
remove_match_string_non_blocking
(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.
Parameters: - rule : str
The match rule
Raises DBusExceptionDBusException: on error.
Since: 0.80.0
-
request_name
(name, flags=0)¶ 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 DBusExceptionDBusException: if the bus daemon cannot be contacted or returns an error.
-
start_service_by_name
(bus_name, flags=0)¶ 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 DBusExceptionDBusException: if the service could not be started.
Since: 0.80.0
-
watch_name_owner
(bus_name, callback)¶ 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
-