client: use async call instead of sync call
[profile/ivi/automotive-message-broker.git] / tests / amb-listen.py
1 #!/usr/bin/python
2
3 import dbus
4 import sys
5 import argparse
6 import gobject
7 import json
8 from dbus.mainloop.glib import DBusGMainLoop
9
10 print "This application is deprecated.  It will disappear in the future.  Use ambctl"
11
12 def print_data(interface, properties, invalidated):
13         print json.dumps(properties, indent=2)
14
15 parser = argparse.ArgumentParser()
16 parser.add_argument("get", help="get {objectName}")
17 args = parser.parse_args()
18
19 objectName = args.get
20
21 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
22 bus = dbus.SystemBus()
23 managerObject = bus.get_object("org.automotive.message.broker", "/");
24 managerInterface = dbus.Interface(managerObject, "org.automotive.Manager")
25
26 objects = managerInterface.FindObject(objectName);
27
28 for o in objects:
29         bus.add_signal_receiver(print_data,
30                                 dbus_interface="org.freedesktop.DBus.Properties",
31                                 signal_name="PropertiesChanged",
32                                                                                                                                 path=o)
33
34 loop = gobject.MainLoop()
35 loop.run()