[tor-commits] [nyx/master] Errors when rendering connection panel entry

atagar at torproject.org atagar at torproject.org
Sat Jun 27 21:20:49 UTC 2015


commit 91cff237a45cb9aa7d1aae53017627dc6e267083
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Jun 8 09:22:23 2015 -0700

    Errors when rendering connection panel entry
    
    Stacktraces related to how we handle curses attributes on the connection
    panel. This arose if you tried to view the panel when there was... well,
    anything on it (usually if you disable DisableDebuggerAttachment).
    
      Traceback (most recent call last):
        File "./run_nyx", line 8, in <module>
          nyx.main()
        File "/home/atagar/Desktop/nyx/nyx/__init__.py", line 30, in main
          nyx.starter.main()
        File "/home/atagar/Desktop/nyx/stem/util/conf.py", line 288, in wrapped
          return func(*args, config = config, **kwargs)
        File "/home/atagar/Desktop/nyx/nyx/starter.py", line 91, in main
          curses.wrapper(nyx.controller.start_nyx)
        File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
          return func(stdscr, *args, **kwds)
        File "/home/atagar/Desktop/nyx/nyx/controller.py", line 576, in start_nyx
          control.redraw(False)
        File "/home/atagar/Desktop/nyx/nyx/controller.py", line 402, in redraw
          panel_impl.redraw(force)
        File "/home/atagar/Desktop/nyx/nyx/util/panel.py", line 433, in redraw
          self.draw(self.max_x, self.max_y)
        File "/home/atagar/Desktop/nyx/nyx/connections/conn_panel.py", line 464, in draw
          attr |= extra_format
      TypeError: unsupported operand type(s) for |=: 'str' and 'int'
    
      Traceback (most recent call last):
        File "./run_nyx", line 8, in <module>
          nyx.main()
        File "/home/atagar/Desktop/nyx/nyx/__init__.py", line 30, in main
          nyx.starter.main()
        File "/home/atagar/Desktop/nyx/stem/util/conf.py", line 288, in wrapped
          return func(*args, config = config, **kwargs)
        File "/home/atagar/Desktop/nyx/nyx/starter.py", line 91, in main
          curses.wrapper(nyx.controller.start_nyx)
        File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
          return func(stdscr, *args, **kwds)
        File "/home/atagar/Desktop/nyx/nyx/controller.py", line 576, in start_nyx
          control.redraw(False)
        File "/home/atagar/Desktop/nyx/nyx/controller.py", line 402, in redraw
          panel_impl.redraw(force)
        File "/home/atagar/Desktop/nyx/nyx/util/panel.py", line 433, in redraw
          self.draw(self.max_x, self.max_y)
        File "/home/atagar/Desktop/nyx/nyx/connections/conn_panel.py", line 463, in draw
          for msg, attr in draw_entry:
      ValueError: too many values to unpack
---
 nyx/connections/circ_entry.py |    4 +++-
 nyx/connections/conn_entry.py |    6 ++++--
 nyx/connections/conn_panel.py |    2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/nyx/connections/circ_entry.py b/nyx/connections/circ_entry.py
index b3738c1..b3dc113 100644
--- a/nyx/connections/circ_entry.py
+++ b/nyx/connections/circ_entry.py
@@ -10,6 +10,8 @@ followed by an entry for each hop in the circuit. For instance:
 
 import curses
 
+import nyx.util.ui_tools
+
 from nyx.connections import entries, conn_entry
 from nyx.util import tor_controller
 
@@ -172,7 +174,7 @@ class CircLine(conn_entry.ConnectionLine):
     return entries.ConnectionPanelLine.get_listing_entry(self, width, current_time, listing_type)
 
   def _get_listing_entry(self, width, current_time, listing_type):
-    line_format = conn_entry.CATEGORY_COLOR[self.get_type()]
+    line_format = nyx.util.ui_tools.get_color(conn_entry.CATEGORY_COLOR[self.get_type()])
 
     # The required widths are the sum of the following:
     # initial space (1 character)
diff --git a/nyx/connections/conn_entry.py b/nyx/connections/conn_entry.py
index cfd4fa3..714661e 100644
--- a/nyx/connections/conn_entry.py
+++ b/nyx/connections/conn_entry.py
@@ -6,6 +6,8 @@ Connection panel entries related to actual connections to or from the system
 import time
 import curses
 
+import nyx.util.ui_tools
+
 from nyx.util import tor_controller
 from nyx.connections import entries
 
@@ -374,14 +376,14 @@ class ConnectionLine(entries.ConnectionPanelLine):
     # category - "<type>"
     # postType - ")   "
 
-    line_format = CATEGORY_COLOR[entry_type]
+    line_format = nyx.util.ui_tools.get_color(CATEGORY_COLOR[entry_type])
     time_width = 6 if CONFIG['features.connection.markInitialConnections'] else 5
 
     draw_entry = [(' ', line_format),
                   (self._get_listing_content(width - (12 + time_width) - 1, listing_type), line_format),
                   (' ' * time_width, line_format),
                   (' (', line_format),
-                  (entry_type.upper(), line_format, curses.A_BOLD),
+                  (entry_type.upper(), line_format | curses.A_BOLD),
                   (')' + ' ' * (9 - len(entry_type)), line_format)]
 
     return draw_entry
diff --git a/nyx/connections/conn_panel.py b/nyx/connections/conn_panel.py
index 290cc84..46c4a7c 100644
--- a/nyx/connections/conn_panel.py
+++ b/nyx/connections/conn_panel.py
@@ -462,7 +462,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
 
       for msg, attr in draw_entry:
         attr |= extra_format
-        self.addstr(draw_line, x_offset, msg, *attr)
+        self.addstr(draw_line, x_offset, msg, attr)
         x_offset += len(msg)
 
       if draw_line >= height:





More information about the tor-commits mailing list