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