fail less
[uccdoor.git] / client-json.py
1 #! /usr/bin/python
2 # UCC Door Server - client which outputs JSON
3 # David Adam <[email protected]>
4 # Released under an MIT-style license; see COPYING for details.
5
6 import dbus
7
8 if __name__ == '__main__':
9     
10     # get on the bus
11     system_bus = dbus.SystemBus()
12     
13     doors = ('uccdoor', 'unisfadoor', 'chdoor', 'mrdoor', 'uccpir')
14     
15     objects = (system_bus.get_object('au.asn.ucc.DoorServer', '/au/asn/ucc/doors/%s' % door)
16             for door in doors)
17     statuses = (remote_object.get_status(dbus_interface='au.asn.ucc.DoorInterface')
18             for remote_object in objects)
19     status_ints = (int(x) for x in statuses)
20     
21     print "Content-Type: text/json"
22     print
23     print dict(zip(doors, status_ints))

UCC git Repository :: git.ucc.asn.au