4
from optparse import OptionParser
10
'last_checked_ok': 'Last Successful Check',
12
'interval': 'Interval',
14
'fingerprint': 'Fingerprint',
15
'checker_running': 'Check Is Running',
16
'last_enabled': 'Last Enabled',
19
busname = 'org.mandos-system.Mandos'
20
object_path = '/Mandos'
21
interface = 'org.mandos_system.Mandos'
23
defaultkeywords = ('name', 'enabled', 'timeout', 'last_checked_ok', 'checker')
25
parser = OptionParser(version = "%%prog %s" % version)
26
parser.add_option("-a", "--all", action="store_true", default=False,
27
help="Print all fields")
28
options = parser.parse_args()[0]
30
keywords = ( 'name', 'enabled', 'timeout', 'last_checked_ok',
31
'created', 'interval', 'host', 'fingerprint',
32
'checker_running', 'last_enabled', 'checker' )
34
keywords = defaultkeywords
37
bus = dbus.SystemBus()
38
mandos_dbus_objc = bus.get_object(busname, object_path)
39
mandos_serv = dbus.Interface(mandos_dbus_objc, dbus_interface = interface)
40
mandos_clients = mandos_serv.GetAllClientsWithProperties()
43
if type(x) is dbus.Boolean:
44
return "Yes" if x else "No"
48
format_string = ' '.join('%%-%ds'
49
% max(len(tablewords[key]),
50
max(len(valuetostring(client[key]))
52
in mandos_clients.itervalues()))
54
print format_string % tuple(tablewords[key] for key in keywords)
55
for client in mandos_clients.itervalues():
56
print format_string % tuple(valuetostring(client[key]) for key in keywords)