From: David Adam (zanchey) Date: Sun, 18 Oct 2009 08:24:34 +0000 (+0800) Subject: client-finger: add fake finger client for cfingerd(8) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=e1cb1bae6e4c5a2610b34dfa8c449dd1590645eb;p=uccdoor.git client-finger: add fake finger client for cfingerd(8) --- 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 +