/mandos/release

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

« back to all changes in this revision

Viewing changes to mandos-monitor

  • Committer: Teddy Hogeborn
  • Date: 2014-07-13 21:02:53 UTC
  • Revision ID: teddy@recompile.se-20140713210253-ftnydds0bnvbzxaa
Tags: version-1.6.6-1
* Makefile (version): Changed to "1.6.6".
* NEWS (Version 1.6.6): New entry.
* debian/changelog (1.6.6-1): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
                                         self.rejected,
162
162
                                         client_interface,
163
163
                                         byte_arrays=True))
164
 
        self.logger('Created client {0}'
165
 
                    .format(self.properties["Name"]), level=0)
 
164
        #self.logger('Created client {0}'
 
165
        #            .format(self.properties["Name"]))
166
166
    
167
167
    def using_timer(self, flag):
168
168
        """Call this method with True or False when timer should be
179
179
    
180
180
    def checker_completed(self, exitstatus, condition, command):
181
181
        if exitstatus == 0:
182
 
            self.logger('Checker for client {0} (command "{1}")'
183
 
                        ' succeeded'.format(self.properties["Name"],
184
 
                                            command), level=0)
185
182
            self.update()
186
183
            return
187
184
        # Checker failed
206
203
        self.update()
207
204
    
208
205
    def checker_started(self, command):
209
 
        """Server signals that a checker started."""
210
 
        self.logger('Client {0} started checker "{1}"'
211
 
                    .format(self.properties["Name"],
212
 
                            command), level=0)
 
206
        """Server signals that a checker started. This could be useful
 
207
           to log in the future. """
 
208
        #self.logger('Client {0} started checker "{1}"'
 
209
        #            .format(self.properties["Name"],
 
210
        #                    str(command)))
 
211
        pass
213
212
    
214
213
    def got_secret(self):
215
214
        self.logger('Client {0} received its secret'
404
403
    """This is the entire user interface - the whole screen
405
404
    with boxes, lists of client widgets, etc.
406
405
    """
407
 
    def __init__(self, max_log_length=1000, log_level=1):
 
406
    def __init__(self, max_log_length=1000):
408
407
        DBusGMainLoop(set_as_default=True)
409
408
        
410
409
        self.screen = urwid.curses_display.Screen()
448
447
        self.log = []
449
448
        self.max_log_length = max_log_length
450
449
        
451
 
        self.log_level = log_level
452
 
        
453
450
        # We keep a reference to the log widget so we can remove it
454
451
        # from the ListWalker without it getting destroyed
455
452
        self.logbox = ConstrainedListBox(self.log)
489
486
            self.uilist.append(self.logbox)
490
487
        self.topwidget = urwid.Pile(self.uilist)
491
488
    
492
 
    def log_message(self, message, level=1):
 
489
    def log_message(self, message):
493
490
        """Log message formatted with timestamp"""
494
 
        if level < self.log_level:
495
 
            return
496
491
        timestamp = datetime.datetime.now().isoformat()
497
 
        self.log_message_raw("{0}: {1}".format(timestamp, message),
498
 
                             level=level)
 
492
        self.log_message_raw(timestamp + ": " + message)
499
493
    
500
 
    def log_message_raw(self, markup, level=1):
 
494
    def log_message_raw(self, markup):
501
495
        """Add a log message to the log buffer."""
502
 
        if level < self.log_level:
503
 
            return
504
496
        self.log.append(urwid.Text(markup, wrap=self.log_wrap))
505
497
        if (self.max_log_length
506
498
            and len(self.log) > self.max_log_length):
513
505
        """Toggle visibility of the log buffer."""
514
506
        self.log_visible = not self.log_visible
515
507
        self.rebuild()
516
 
        self.log_message("Log visibility changed to: {0}"
517
 
                         .format(self.log_visible), level=0)
 
508
        #self.log_message("Log visibility changed to: "
 
509
        #                 + str(self.log_visible))
518
510
    
519
511
    def change_log_display(self):
520
512
        """Change type of log display.
525
517
            self.log_wrap = "clip"
526
518
        for textwidget in self.log:
527
519
            textwidget.set_wrap_mode(self.log_wrap)
528
 
        self.log_message("Wrap mode: {0}".format(self.log_wrap),
529
 
                         level=0)
 
520
        #self.log_message("Wrap mode: " + self.log_wrap)
530
521
    
531
522
    def find_and_remove_client(self, path, name):
532
523
        """Find a client by its object path and remove it.
679
670
                                            "?: Help",
680
671
                                            "l: Log window toggle",
681
672
                                            "TAB: Switch window",
682
 
                                            "w: Wrap (log lines)",
683
 
                                            "v: Toggle verbose log",
684
 
                                            ))))
 
673
                                            "w: Wrap (log)"))))
685
674
                self.log_message_raw(("bold",
686
675
                                      "  "
687
676
                                      .join(("Clients:",
700
689
                else:
701
690
                    self.topwidget.set_focus(self.logbox)
702
691
                self.refresh()
703
 
            elif key == "v":
704
 
                if self.log_level == 0:
705
 
                    self.log_level = 1
706
 
                    self.log_message("Verbose mode: Off")
707
 
                else:
708
 
                    self.log_level = 0
709
 
                    self.log_message("Verbose mode: On")
710
692
            #elif (key == "end" or key == "meta >" or key == "G"
711
693
            #      or key == ">"):
712
694
            #    pass            # xxx end-of-buffer