From: David Adam (zanchey) Date: Sat, 10 Oct 2009 14:50:47 +0000 (+0800) Subject: client-json.py: import client which outputs JSON X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=7faf89e41a8087ed71073a0d84a7334847ba76ad;p=uccdoor.git client-json.py: import client which outputs JSON --- diff --git a/client-json.py b/client-json.py new file mode 100755 index 0000000..1733033 --- /dev/null +++ b/client-json.py @@ -0,0 +1,26 @@ +#! /usr/bin/python +# UCC Door Server - client which outputs JSON +# David Adam +# Released under an MIT-style license; see COPYING for details. + +import dbus + +if __name__ == '__main__': + + # get on the bus + system_bus = dbus.SystemBus() + + doors = {'uccdoor': None, 'unisfadoor': None, 'chdoor': None, 'mrdoor': None, 'uccpir': None} + + for door in doors.keys(): + doors[door] = system_bus.get_object('au.asn.ucc.DoorServer', '/au/asn/ucc/doors/%s' % door) + + print "Content-Type: text/json" + print + print "{" + + for door, remote_object in doors.items(): + status = remote_object.get_status(dbus_interface='au.asn.ucc.DoorInterface') + print '"%s": %d,' % (door, status) + + print "}"