1 # UCC Door Server - example synchronous client
3 # Released under an MIT-style license; see COPYING for details.
8 def signal_handler(new_status, path):
9 door = path.split('/')[-1:][0]
12 print "Received new status %d from %s" % (new_status, door)
14 if __name__ == '__main__':
16 from dbus.mainloop.glib import DBusGMainLoop
17 DBusGMainLoop(set_as_default=True)
19 system_bus = dbus.SystemBus()
21 doors = {'uccdoor': None, 'unisfadoor': None, 'chdoor': None, 'mrdoor': None, 'uccpir': None}
23 # According to the D-BUS documentation, you shouldn't create an object just
24 # to listen to a signal, as this may cause server activation. However, your
25 # client might like to do more clever things with the object.
26 for door in doors.keys():
27 doors[door] = system_bus.get_object('au.asn.ucc.DoorServer', '/au/asn/ucc/doors/%s' % door)
29 for door, remote_object in doors.items():
30 remote_object.connect_to_signal('status_changed', signal_handler,
31 dbus_interface='au.asn.ucc.DoorInterface',
35 loop = gobject.MainLoop()