2
# -*- mode: python; coding: utf-8 -*-
5
from optparse import OptionParser
8
locale.setlocale(locale.LC_ALL, u'')
12
'enabled': u'Enabled',
13
'timeout': u'Timeout',
14
'last_checked_ok': u'Last Successful Check',
15
'created': u'Created',
16
'interval': u'Interval',
18
'fingerprint': u'Fingerprint',
19
'checker_running': u'Check Is Running',
20
'last_enabled': u'Last Enabled',
21
'checker': u'Checker',
23
busname = 'org.mandos-system.Mandos'
24
object_path = '/Mandos'
25
interface = 'org.mandos_system.Mandos'
27
defaultkeywords = ('name', 'enabled', 'timeout', 'last_checked_ok',
30
parser = OptionParser(version = "%%prog %s" % version)
31
parser.add_option("-a", "--all", action="store_true", default=False,
32
help="Print all fields")
33
options = parser.parse_args()[0]
35
keywords = ('name', 'enabled', 'timeout', 'last_checked_ok',
36
'created', 'interval', 'host', 'fingerprint',
37
'checker_running', 'last_enabled', 'checker')
39
keywords = defaultkeywords
42
bus = dbus.SystemBus()
43
mandos_dbus_objc = bus.get_object(busname, object_path)
44
mandos_serv = dbus.Interface(mandos_dbus_objc,
45
dbus_interface = interface)
46
mandos_clients = mandos_serv.GetAllClientsWithProperties()
49
if type(x) is dbus.Boolean:
50
return u"Yes" if x else u"No"
54
format_string = u' '.join(u'%%-%ds'
55
% max(len(tablewords[key]),
56
max(len(valuetostring(client[key]))
58
in mandos_clients.itervalues()))
60
print format_string % tuple(tablewords[key] for key in keywords)
61
for client in mandos_clients.itervalues():
62
print format_string % tuple(valuetostring(client[key])