duh
[uccdoor.git] / client-finger.py
1 #!/usr/bin/env python
2
3 # UCC Door Server - fake finger client for cfingerd(8)
4 # David Adam <[email protected]>
5 # Released under an MIT-style license; see COPYING for details.
6
7 # incorporate into the cfingerd.conf(5) file with a line similar to:
8 # FILES finger_fakeusers = {
9 #         "door", "The Doors", FALSE, "/home/other/door/uccdoor/client-finger.py"
10 # }
11
12 import dbus
13
14 # status strings
15 doorstrings = {0: 'The door is currently closed.',
16         1: 'The door is currently open.',
17         -1: 'The door sensor is currently malfunctioning.',}
18
19 pirstrings = {0: 'There is nothing moving here.',
20         1: 'There is something moving here.',
21         -1: 'There is a malfunctioning PIR here.',}
22
23 if __name__ == '__main__':
24     
25     # get on the bus
26     system_bus = dbus.SystemBus()
27     
28     doors = {'uccdoor': None, 'unisfadoor': None, 'chdoor': None, 'mrdoor': None, 'uccpir': None}
29     
30     for door in doors.keys():
31         try:
32             remote_object = system_bus.get_object('au.asn.ucc.DoorServer', '/au/asn/ucc/doors/%s' % door)
33             state = remote_object.get_status(dbus_interface='au.asn.ucc.DoorInterface')
34         except:
35             state = -1
36         # map the status to a string
37         if door == 'uccpir':
38             doors[door] = pirstrings[state]
39         else:
40             doors[door] = doorstrings[state]
41
42     print """The doors...
43
44 The UCC door:
45   %(uccdoor)s
46   %(uccpir)s
47
48 The UCC Machine Room door:
49   %(mrdoor)s
50
51 The UniSFA door:
52   %(unisfadoor)s
53
54 The Cameron Hall top door:
55   %(chdoor)s
56
57 Bing.""" % doors
58

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