/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: 2015-08-02 16:45:29 UTC
  • Revision ID: teddy@recompile.se-20150802164529-pemtk1agiqluoiua
Deprecate some D-Bus methods in favor of D-Bus properties.

The following D-Bus methods on the interface
"se.recompile.Mandos.Client" are redundant, and are therefore
deprecated:  "Disable", "Enable", "StartChecker", and "StopChecker".
Instead, the D-Bus properties "Enabled" and "CheckerRunning" should be
set, as was always also possible.

* DBUS-API (se.recompile.Mandos.Client.Disable): Remove; deprecated.
  (se.recompile.Mandos.Client.Enable): - '' -
  (se.recompile.Mandos.Client.StartChecker): - '' -
  (se.recompile.Mandos.Client.StopChecker): - '' -
* mandos (ClientDBus.Enable): Annotate as deprecated.
  (ClientDBus.StartChecker): - '' -
  (ClientDBus.Disable): - '' -
  (ClientDBus.StopChecker): - '' -
* mandos-monitor (MandosClientWidget.keypress): Set properties instead
                                                of calling deprecated
                                                methods.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
4
4
# Mandos Monitor - Control and monitor the Mandos server
5
5
6
 
# Copyright © 2009-2014 Teddy Hogeborn
7
 
# Copyright © 2009-2014 Björn Påhlsson
 
6
# Copyright © 2009-2015 Teddy Hogeborn
 
7
# Copyright © 2009-2015 Björn Påhlsson
8
8
9
9
# This program is free software: you can redistribute it and/or modify
10
10
# it under the terms of the GNU General Public License as published by
60
60
domain = 'se.recompile'
61
61
server_interface = domain + '.Mandos'
62
62
client_interface = domain + '.Mandos.Client'
63
 
version = "1.6.8"
 
63
version = "1.6.9"
64
64
 
65
65
def isoformat_to_datetime(iso):
66
66
    "Parse an ISO 8601 date string to a datetime.datetime()"
173
173
            gobject.source_remove(self._update_timer_callback_tag)
174
174
            self._update_timer_callback_tag = None
175
175
    
176
 
    def checker_completed(self, exitstatus, condition, command):
 
176
    def checker_completed(self, exitstatus, signal, command):
177
177
        if exitstatus == 0:
178
178
            self.logger('Checker for client {} (command "{}")'
179
179
                        ' succeeded'.format(self.properties["Name"],
181
181
            self.update()
182
182
            return
183
183
        # Checker failed
184
 
        if os.WIFEXITED(condition):
 
184
        if exitstatus >= 0:
185
185
            self.logger('Checker for client {} (command "{}") failed'
186
186
                        ' with exit code {}'
187
187
                        .format(self.properties["Name"], command,
188
 
                                os.WEXITSTATUS(condition)))
189
 
        elif os.WIFSIGNALED(condition):
 
188
                                exitstatus))
 
189
        elif signal != 0:
190
190
            self.logger('Checker for client {} (command "{}") was'
191
191
                        ' killed by signal {}'
192
192
                        .format(self.properties["Name"], command,
193
 
                                os.WTERMSIG(condition)))
194
 
        elif os.WCOREDUMP(condition):
195
 
            self.logger('Checker for client {} (command "{}") dumped'
196
 
                        ' core'.format(self.properties["Name"],
197
 
                                       command))
 
193
                                signal))
198
194
        else:
199
195
            self.logger('Checker for client {} completed'
200
196
                        ' mysteriously'
337
333
        """Handle keys.
338
334
        This overrides the method from urwid.FlowWidget"""
339
335
        if key == "+":
340
 
            self.proxy.Enable(dbus_interface = client_interface,
341
 
                              ignore_reply=True)
 
336
            self.proxy.Set(client_interface, "Enabled",
 
337
                           dbus.Boolean(True), ignore_reply = True,
 
338
                           dbus_interface = dbus.PROPERTIES_IFACE)
342
339
        elif key == "-":
343
 
            self.proxy.Disable(dbus_interface = client_interface,
344
 
                               ignore_reply=True)
 
340
            self.proxy.Set(client_interface, "Enabled", False,
 
341
                           ignore_reply = True,
 
342
                           dbus_interface = dbus.PROPERTIES_IFACE)
345
343
        elif key == "a":
346
344
            self.proxy.Approve(dbus.Boolean(True, variant_level=1),
347
345
                               dbus_interface = client_interface,
355
353
                                                  .object_path,
356
354
                                                  ignore_reply=True)
357
355
        elif key == "s":
358
 
            self.proxy.StartChecker(dbus_interface = client_interface,
359
 
                                    ignore_reply=True)
 
356
            self.proxy.Set(client_interface, "CheckerRunning",
 
357
                           dbus.Boolean(True), ignore_reply = True,
 
358
                           dbus_interface = dbus.PROPERTIES_IFACE)
360
359
        elif key == "S":
361
 
            self.proxy.StopChecker(dbus_interface = client_interface,
362
 
                                   ignore_reply=True)
 
360
            self.proxy.Set(client_interface, "CheckerRunning",
 
361
                           dbus.Boolean(False), ignore_reply = True,
 
362
                           dbus_interface = dbus.PROPERTIES_IFACE)
363
363
        elif key == "C":
364
364
            self.proxy.CheckedOK(dbus_interface = client_interface,
365
365
                                 ignore_reply=True)