/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 at bsnet
  • Date: 2011-02-11 18:54:14 UTC
  • mto: (237.7.13 mandos)
  • mto: This revision was merged to the branch mainline in revision 282.
  • Revision ID: teddy@fukt.bsnet.se-20110211185414-cjmw3hppv9i3h9wh
* mandos-monitor: Use only unicode string literals.
  (MandosClientWidget.rows, MandosClientWidget.render,
  MandosClientWidget.keypress, ConstrainedListBox.keypress) Don't use
                                                            argument
                                                            tuple
                                                            unpacking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
locale.setlocale(locale.LC_ALL, u'')
46
46
 
47
47
import logging
48
 
logging.getLogger('dbus.proxies').setLevel(logging.CRITICAL)
 
48
logging.getLogger(u'dbus.proxies').setLevel(logging.CRITICAL)
49
49
 
50
50
# Some useful constants
51
 
domain = 'se.bsnet.fukt'
52
 
server_interface = domain + '.Mandos'
53
 
client_interface = domain + '.Mandos.Client'
54
 
version = "1.2.1"
 
51
domain = u'se.bsnet.fukt'
 
52
server_interface = domain + u'.Mandos'
 
53
client_interface = domain + u'.Mandos.Client'
 
54
version = u"1.2.3"
55
55
 
56
56
# Always run in monochrome mode
57
57
urwid.curses_display.curses.has_colors = lambda : False
259
259
        This overrides the method from urwid.FlowWidget."""
260
260
        return True
261
261
    
262
 
    def rows(self, (maxcol,), focus=False):
 
262
    def rows(self, maxcolrow, focus=False):
263
263
        """How many rows this widget will occupy might depend on
264
264
        whether we have focus or not.
265
265
        This overrides the method from urwid.FlowWidget"""
266
 
        return self.current_widget(focus).rows((maxcol,), focus=focus)
 
266
        return self.current_widget(focus).rows(maxcolrow, focus=focus)
267
267
    
268
268
    def current_widget(self, focus=False):
269
269
        if focus or self.opened:
318
318
                           % unicode(timer).rsplit(".", 1)[0])
319
319
        else:
320
320
            message = u"enabled"
321
 
        self._text = "%s%s" % (base, message)
 
321
        self._text = u"%s%s" % (base, message)
322
322
            
323
323
        if not urwid.supports_unicode():
324
 
            self._text = self._text.encode("ascii", "replace")
 
324
            self._text = self._text.encode(u"ascii", u"replace")
325
325
        textlist = [(u"normal", self._text)]
326
326
        self._text_widget.set_text(textlist)
327
327
        self._focus_text_widget.set_text([(with_standout[text[0]],
331
331
                                          for text in textlist])
332
332
        self._widget = self._text_widget
333
333
        self._focus_widget = urwid.AttrWrap(self._focus_text_widget,
334
 
                                            "standout")
 
334
                                            u"standout")
335
335
        # Run update hook, if any
336
336
        if self.update_hook is not None:
337
337
            self.update_hook()
348
348
        if self.delete_hook is not None:
349
349
            self.delete_hook(self)
350
350
    
351
 
    def render(self, (maxcol,), focus=False):
 
351
    def render(self, maxcolrow, focus=False):
352
352
        """Render differently if we have focus.
353
353
        This overrides the method from urwid.FlowWidget"""
354
 
        return self.current_widget(focus).render((maxcol,),
 
354
        return self.current_widget(focus).render(maxcolrow,
355
355
                                                 focus=focus)
356
356
    
357
 
    def keypress(self, (maxcol,), key):
 
357
    def keypress(self, maxcolrow, key):
358
358
        """Handle keys.
359
359
        This overrides the method from urwid.FlowWidget"""
360
360
        if key == u"+":
403
403
    "down" key presses, thus not allowing any containing widgets to
404
404
    use them as an excuse to shift focus away from this widget.
405
405
    """
406
 
    def keypress(self, (maxcol, maxrow), key):
407
 
        ret = super(ConstrainedListBox, self).keypress((maxcol,
408
 
                                                        maxrow), key)
 
406
    def keypress(self, maxcolrow, key):
 
407
        ret = super(ConstrainedListBox, self).keypress(maxcolrow, key)
409
408
        if ret in (u"up", u"down"):
410
409
            return
411
410
        return ret