From 7faf89e41a8087ed71073a0d84a7334847ba76ad Mon Sep 17 00:00:00 2001 From: "David Adam (zanchey)" Date: Sat, 10 Oct 2009 22:50:47 +0800 Subject: [PATCH] client-json.py: import client which outputs JSON --- client-json.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 client-json.py 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 "}" -- 2.20.1