/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-monitor

  • Committer: Teddy Hogeborn
  • Date: 2019-11-03 18:58:44 UTC
  • Revision ID: teddy@recompile.se-20191103185844-r5ghn595fdzefg4w
mandos-monitor: Formatting changes only

* mandos-monitor: Re-order imports and normally use double quotes
                  instead of single quotes for strings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
import os
36
36
import warnings
37
37
import datetime
 
38
import locale
 
39
import logging
38
40
 
39
41
import urwid.curses_display
40
42
import urwid
44
46
 
45
47
import dbus
46
48
 
47
 
import locale
48
 
 
49
 
import logging
50
 
 
51
49
if sys.version_info.major == 2:
52
50
    str = unicode
53
51
 
57
55
 
58
56
logging.captureWarnings(True)   # Show warnings via the logging system
59
57
 
60
 
locale.setlocale(locale.LC_ALL, '')
 
58
locale.setlocale(locale.LC_ALL, "")
61
59
 
62
 
logging.getLogger('dbus.proxies').setLevel(logging.CRITICAL)
 
60
logging.getLogger("dbus.proxies").setLevel(logging.CRITICAL)
63
61
 
64
62
# Some useful constants
65
 
domain = 'se.recompile'
66
 
server_interface = domain + '.Mandos'
67
 
client_interface = domain + '.Mandos.Client'
 
63
domain = "se.recompile"
 
64
server_interface = domain + ".Mandos"
 
65
client_interface = domain + ".Mandos.Client"
68
66
version = "1.8.9"
69
67
 
70
68
try:
167
165
                                         self.rejected,
168
166
                                         client_interface,
169
167
                                         byte_arrays=True))
170
 
        log.debug('Created client %s', self.properties["Name"])
 
168
        log.debug("Created client %s", self.properties["Name"])
171
169
 
172
170
    def using_timer(self, flag):
173
171
        """Call this method with True or False when timer should be
185
183
    def checker_completed(self, exitstatus, condition, command):
186
184
        if exitstatus == 0:
187
185
            log.debug('Checker for client %s (command "%s")'
188
 
                      ' succeeded', self.properties["Name"], command)
 
186
                      " succeeded", self.properties["Name"], command)
189
187
            self.update()
190
188
            return
191
189
        # Checker failed
192
190
        if os.WIFEXITED(condition):
193
191
            log.info('Checker for client %s (command "%s") failed'
194
 
                     ' with exit code %d', self.properties["Name"],
 
192
                     " with exit code %d", self.properties["Name"],
195
193
                     command, os.WEXITSTATUS(condition))
196
194
        elif os.WIFSIGNALED(condition):
197
195
            log.info('Checker for client %s (command "%s") was'
198
 
                     ' killed by signal %d', self.properties["Name"],
 
196
                     " killed by signal %d", self.properties["Name"],
199
197
                     command, os.WTERMSIG(condition))
200
198
        self.update()
201
199
 
249
247
        # Rebuild focus and non-focus widgets using current properties
250
248
 
251
249
        # Base part of a client. Name!
252
 
        base = '{name}: '.format(name=self.properties["Name"])
 
250
        base = "{name}: ".format(name=self.properties["Name"])
253
251
        if not self.properties["Enabled"]:
254
252
            message = "DISABLED"
255
253
            self.using_timer(False)
277
275
                timer = datetime.timedelta(0)
278
276
            else:
279
277
                expires = (datetime.datetime.strptime
280
 
                           (expires, '%Y-%m-%dT%H:%M:%S.%f'))
 
278
                           (expires, "%Y-%m-%dT%H:%M:%S.%f"))
281
279
                timer = max(expires - datetime.datetime.utcnow(),
282
280
                            datetime.timedelta())
283
 
            message = ('A checker has failed! Time until client'
284
 
                       ' gets disabled: {}'
 
281
            message = ("A checker has failed! Time until client"
 
282
                       " gets disabled: {}"
285
283
                       .format(str(timer).rsplit(".", 1)[0]))
286
284
            self.using_timer(True)
287
285
        else:
471
469
                           "Mandos Monitor version " + version))
472
470
        self.add_log_line(("bold", "q: Quit  ?: Help"))
473
471
 
474
 
        self.busname = domain + '.Mandos'
 
472
        self.busname = domain + ".Mandos"
475
473
        self.main_loop = GLib.MainLoop()
476
474
 
477
475
    def client_not_found(self, key_id, address):