Core API¶
Message constructors¶
-
jeepney.new_method_call(remote_obj, method, signature=None, body=())[source]¶ Construct a new method call message
This is a relatively low-level method. In many cases, this will be called from a
MessageGeneratorsubclass which provides a more convenient API.Parameters: - remote_obj (DBusAddress) – The object to call a method on
- method (str) – The name of the method to call
- signature (str) – The DBus signature of the body data
- body (tuple) – Body data (i.e. method parameters)
-
jeepney.new_method_return(parent_msg, signature=None, body=())[source]¶ Construct a new response message
Parameters:
-
jeepney.new_error(parent_msg, error_name, signature=None, body=())[source]¶ Construct a new error response message
Parameters:
-
jeepney.new_signal(emitter, signal, signature=None, body=())[source]¶ Construct a new signal message
Parameters: - emitter (DBusAddress) – The object sending the signal
- signal (str) – The name of the signal
- signature (str) – The DBus signature of the body data
- body (tuple) – Body data
-
class
jeepney.DBusAddress(object_path, bus_name=None, interface=None)[source]¶ This identifies the object and interface a message is for.
e.g. messages to display desktop notifications would have this address:
DBusAddress('/org/freedesktop/Notifications', bus_name='org.freedesktop.Notifications', interface='org.freedesktop.Notifications')
Message objects¶
-
class
jeepney.Message(header, body)[source]¶ Object representing a DBus message.
It’s not normally necessary to construct this directly: use higher level functions and methods instead.
-
body¶ A tuple of the data in this message. The number and types of the elements depend on the message’s signature:
D-Bus type D-Bus code Python type BYTE yint BOOLEAN bbool INT16 nint UINT16 qint INT32 iint UINT32 uint INT64 xint UINT64 tint DOUBLE dfloat STRING sstr OBJECT_PATH ostr SIGNATURE gstr ARRAY alist STRUCT ()tuple VARIANT v2-tuple (signature, value)DICT_ENTRY {}dict (for array of dict entries) UNIX_FD hSee Sending & receiving file descriptors
-
serialise(serial=None, fds=None) → bytes[source]¶ Convert this message to bytes.
Specifying serial overrides the
msg.header.serialfield, so a connection can use its own serial number without modifying the message.If file-descriptor support is in use, fds should be a
array.arrayobject with type'i'. Any file descriptors in the message will be added to the array. If the message contains FDs, it can’t be serialised without this array.
-
-
class
jeepney.Header(endianness, message_type, flags, protocol_version, body_length, serial, fields)[source]¶ -
endianness¶ Endiannessobject, affecting message serialisation.
-
message_type¶ MessageTypeobject.
-
flags¶ MessageFlagobject.
-
protocol_version¶ Currently always 1.
-
body_length¶ The length of the raw message body in bytes.
-
serial¶ Sender’s serial number for this message. This is not necessarily set for outgoing messages - see
Message.serialise().
-
fields¶ Mapping of
HeaderFieldsvalues to the relevant Python objects.
-
Exceptions¶
Enums & Flags¶
-
class
jeepney.HeaderFields[source]¶ -
path= 1¶
-
interface= 2¶
-
member= 3¶
-
error_name= 4¶
-
reply_serial= 5¶
-
destination= 6¶
-
sender= 7¶
-
signature= 8¶
-
unix_fds= 9¶
-
-
class
jeepney.MessageFlag[source]¶ -
no_reply_expected= 1¶ On a method call message, indicates that a reply should not be sent.
-
no_auto_start= 2¶ D-Bus includes a mechanism to start a service on demand to handle messages. If this flag is set, it will avoid that, only handling the message if the target is already running.
Signals that the recipient may prompt the user for elevated privileges to handle the request. The D-Bus specification has more details.
-
Matching messages¶
-
class
jeepney.MatchRule(*, type=None, sender=None, interface=None, member=None, path=None, path_namespace=None, destination=None, eavesdrop=False)[source]¶ Construct a match rule to subscribe to DBus messages.
e.g.:
mr = MatchRule( interface='org.freedesktop.DBus', member='NameOwnerChanged', type='signal' ) msg = message_bus.AddMatch(mr) # Send this message to subscribe to the signal
MatchRule objects are used both for filtering messages internally, and for setting up subscriptions in the message bus.