client-json.py: import client which outputs JSON
authorDavid Adam (zanchey) <[email protected]>
Sat, 10 Oct 2009 14:50:47 +0000 (22:50 +0800)
committerDavid Adam (zanchey) <[email protected]>
Thu, 15 Oct 2009 12:26:48 +0000 (20:26 +0800)
client-json.py [new file with mode: 0755]

diff --git a/client-json.py b/client-json.py
new file mode 100755 (executable)
index 0000000..1733033
--- /dev/null
@@ -0,0 +1,26 @@
+#! /usr/bin/python
+# UCC Door Server - client which outputs JSON
+# David Adam <[email protected]>
+# 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 "}"

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