Package dbus :: Module lowlevel :: Class Message
[hide private]
[frames] | no frames]

Class Message

source code

object --+
         |
        Message
Known Subclasses:
ErrorMessage, MethodCallMessage, MethodReturnMessage, SignalMessage

A message to be sent or received over a D-Bus Connection.

Instance Methods [hide private]
 
__new__(T, S, ...)
Returns: a new object with type S, a subtype of T
source code
 
append(*args, **kwargs)
Set the message's arguments from the positional parameter, according to the signature given by the signature keyword parameter.
source code
 
copy(message)
Deep-copy the message, resetting the serial number to zero.
source code
 
get_args_list(**kwargs)
Return the message's arguments.
source code
 
get_auto_start(message)
Return true if this message will cause an owner for the destination name to be auto-started.
source code
 
get_destination()
Return the message's destination bus name, or None if none.
source code
 
get_error_name()
Returns: str or None
source code
 
get_interface()
Returns: str or None
source code
 
get_member()
Returns: str or None
source code
 
get_no_reply(message)
Return true if this message need not be replied to.
source code
 
get_path()
Return the message's destination object path (if it's a method call) or source object path (if it's a method reply or a signal) or None (if it has no path).
source code
 
get_path_decomposed()
Return a list of path components (e.g.
source code
 
get_reply_serial(message)
Returns the serial that the message is a reply to or 0 if none.
source code
 
get_sender()
Return the message's sender unique name, or None if none.
source code
 
get_serial(message)
Returns the serial of a message or 0 if none has been specified.
source code
 
get_signature()
Returns: Signature or None
source code
 
get_type(message)
Returns the type of the message.
source code
 
has_destination(...)
has_destination(bus_name: str) -> bool
source code
 
has_interface(...)
has_interface(interface: str or None) -> bool
source code
 
has_member(...)
has_member(name: str or None) -> bool
source code
 
has_path(...)
has_path(name: str or None) -> bool
source code
 
has_sender(...)
has_sender(unique_name: str) -> bool
source code
 
has_signature(...)
has_signature(signature: str) -> bool
source code
 
is_error(...)
is_error(error: str) -> bool
source code
 
is_method_call(...)
is_method_call(interface: str, member: str) -> bool
source code
 
is_signal(...)
is_signal(interface: str, member: str) -> bool
source code
 
set_auto_start(message, bool)
Set whether this message will cause an owner for the destination name to be auto-started.
source code
 
set_destination(...)
set_destination(bus_name: str or None)
source code
 
set_error_name(...)
set_error_name(name: str or None)
source code
 
set_interface(...)
set_interface(name: str or None)
source code
 
set_member(...)
set_member(unique_name: str or None)
source code
 
set_no_reply(message, bool)
Set whether no reply to this message is required.
source code
 
set_path(...)
set_path(name: str or None)
source code
 
set_reply_serial(message, bool)
Set the serial that this message is a reply to.
source code
 
set_sender(...)
set_sender(unique_name: str or None)
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Static Methods [hide private]
 
guess_signature(*args)
Guess a D-Bus signature which should be used to encode the given Python objects.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(T, S, ...)

source code 
Returns:
a new object with type S, a subtype of T

Overrides: object.__new__

append(*args, **kwargs)

source code 

Set the message's arguments from the positional parameter, according to the signature given by the signature keyword parameter.

The following type conversions are supported:

D-Bus (in signature) Python
boolean (b) any object (via bool())
byte (y) string of length 1 any integer
any integer type any integer
double (d) any float
object path anything with a __dbus_object_path__ attribute
string, signature, object path str (must be UTF-8) or unicode
dict (a{...}) any mapping
array (a...) any iterable over appropriate objects
struct ((...)) any iterable over appropriate objects
variant any object above (guess type as below)

Here 'any integer' means anything on which int() or long() (as appropriate) will work, except for basestring subclasses. 'Any float' means anything on which float() will work, except for basestring subclasses.

If there is no signature, guess from the arguments using the static method Message.guess_signature.

copy(message)

source code 
Deep-copy the message, resetting the serial number to zero.
Returns:
Message (or subclass)

get_args_list(**kwargs)

source code 

Return the message's arguments. Keyword arguments control the translation of D-Bus types to Python:

Most of the type mappings should be fairly obvious:

D-Bus Python
byte (y) dbus.Byte (int subclass)
bool (b) dbus.Boolean (int subclass)
Signature (g) dbus.Signature (str subclass)
intNN, uintNN dbus.IntNN, dbus.UIntNN (int or long subclasses)
double (d) dbus.Double
string (s) dbus.String (unicode subclass) (or dbus.UTF8String, str subclass, if utf8_strings set)
Object path (o) dbus.ObjectPath (str subclass)
dict (a{...}) dbus.Dictionary
array (a...) dbus.Array (list subclass) containing appropriate types
byte array (ay) dbus.ByteArray (str subclass) if byte_arrays set; or list of Byte
struct ((...)) dbus.Struct (tuple subclass) of appropriate types
variant (v) contained type, but with variant_level > 0
Parameters:
  • byte_arrays (bool) - If true, convert arrays of byte (signature 'ay') into dbus.ByteArray, a str subclass. In practice, this is usually what you want, but it's off by default for consistency.

    If false (default), convert them into a dbus.Array of Bytes.

  • utf8_strings (bool) - If true, return D-Bus strings as Python 8-bit strings (of UTF-8). If false (default), return D-Bus strings as Python unicode objects.
Returns:
list

get_auto_start(message)

source code 
Return true if this message will cause an owner for the destination name to be auto-started.
Returns:
bool

get_destination()

source code 
Return the message's destination bus name, or None if none.
Returns:
str or None

get_error_name()

source code 
Returns:
str or None

get_interface()

source code 
Returns:
str or None

get_member()

source code 
Returns:
str or None

get_no_reply(message)

source code 
Return true if this message need not be replied to.
Returns:
bool

get_path()

source code 
Return the message's destination object path (if it's a method call) or source object path (if it's a method reply or a signal) or None (if it has no path).
Returns:
ObjectPath or None

get_path_decomposed()

source code 
Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> []) or None if the message has no associated path.
Returns:
list of str, or None

get_reply_serial(message)

source code 
Returns the serial that the message is a reply to or 0 if none.
Returns:
long

get_sender()

source code 
Return the message's sender unique name, or None if none.
Returns:
str or None

get_serial(message)

source code 

Returns the serial of a message or 0 if none has been specified.

The message's serial number is provided by the application sending the message and is used to identify replies to this message. All messages received on a connection will have a serial, but messages you haven't sent yet may return 0.

Returns:
long

get_signature()

source code 
Returns:
Signature or None

get_type(message)

source code 
Returns the type of the message.
Returns:
int

guess_signature(*args)
Static Method

source code 

Guess a D-Bus signature which should be used to encode the given Python objects.

The signature is constructed as follows:

Python D-Bus
D-Bus type, variant_level > 0 variant (v)
D-Bus type, variant_level == 0 the corresponding type
anything with a __dbus_object_path__ attribute object path
bool boolean (y)
any other int subclass int32 (i)
any other long subclass int64 (x)
any other float subclass double (d)
any other str subclass string (s)
any other unicode subclass string (s)
any other tuple subclass struct ((...))
any other list subclass array (a...), guess contents' type according to type of first item
any other dict subclass dict (a{...}), guess key, value type according to types for an arbitrary item
anything else raise TypeError
Returns:
Signature [static method]

set_auto_start(message, bool)

source code 
Set whether this message will cause an owner for the destination name to be auto-started.
Returns:
None

set_no_reply(message, bool)

source code 
Set whether no reply to this message is required.
Returns:
None

set_reply_serial(message, bool)

source code 
Set the serial that this message is a reply to.
Returns:
None