From e1cb1bae6e4c5a2610b34dfa8c449dd1590645eb Mon Sep 17 00:00:00 2001 From: "David Adam (zanchey)" Date: Sun, 18 Oct 2009 16:24:34 +0800 Subject: [PATCH] client-finger: add fake finger client for cfingerd(8) --- client-finger.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 client-finger.py diff --git a/client-finger.py b/client-finger.py new file mode 100755 index 0000000..2171687 --- /dev/null +++ b/client-finger.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# UCC Door Server - fake finger client for cfingerd(8) +# David Adam +# Released under an MIT-style license; see COPYING for details. + +# incorporate into the cfingerd.conf(5) file with a line similar to: +# FILES finger_fakeusers = { +# "door", "The Doors", FALSE, "/home/other/door/uccdoor/client-finger.py" +# } + +import dbus + +# status strings +doorstrings = {0: 'The door is currently closed.', + 1: 'The door is currently open.', + -1: 'The door sensor is currently malfunctioning.',} + +pirstrings = {0: 'There is nothing moving here.', + 1: 'There is something moving here.', + -1: 'There is a malfunctioning PIR here.',} + +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(): + try: + remote_object = system_bus.get_object('au.asn.ucc.DoorServer', '/au/asn/ucc/doors/%s' % door) + state = remote_object.get_status(dbus_interface='au.asn.ucc.DoorInterface') + except: + state = -1 + # map the status to a string + if door == 'uccpir': + doors[door] = pirstrings[state] + else: + doors[door] = doorstrings[state] + + print """The doors... + +The UCC door: + %(uccdoor)s + %(uccpir)s + +The UCC Machine Room door: + %(mrdoor)s + +The UniSFA door: + %(unisfadoor)s + +The Cameron Hall top door: + %(chdoor)s + +Bing.""" % doors + -- 2.20.1