Monitor the dbus messages

Alban Crequy alban.crequy at collabora.co.uk
Wed Mar 12 17:20:14 PDT 2008


Le Wed, 12 Mar 2008 18:04:42 +0100,
Thiago Macieira <thiago at kde.org> a écrit :

> On Wednesday 12 March 2008 17:39:34 thomas wrote:
> > Hi,
> > I want to see the dbus messages. I use the python dbus binding. Is
> > there a possibility to watch the messages on the sockets?
> 
> Use dbus-monitor. It's an external application.

If you want to receive all messages from the bus in python, you can use:

def msg_cb(bus, msg):
    print "== New message =="
    print "type = %d" % msg.get_type()
    print "sender = " + msg.get_sender()

bus = dbus.SessionBus()

# ask dbus-daemon to receive all matching messages
bus.add_match_string("")

# add a callback when receiving a message
bus.add_message_filter(msg_cb)

-- 
Alban


More information about the dbus mailing list