[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Account for event_description() being None



commit afa8e3a17c29e0f3c8f48a0f7c33efe743e7f6ab
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Jun 14 08:32:33 2016 -0700

    Account for event_description() being None
    
    When Stem doesn't recognize an event its event_description() function provides
    None. Accounting for this.
---
 nyx/popups.py | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/nyx/popups.py b/nyx/popups.py
index 3127e67..8cadf05 100644
--- a/nyx/popups.py
+++ b/nyx/popups.py
@@ -411,16 +411,15 @@ def select_event_types(initial_selection):
     subwindow.box()
     subwindow.addstr(0, 0, 'Event Types:', HIGHLIGHT)
 
-    event = None
-    if selection < 5:
-      event = nyx.log.TOR_RUNLEVELS[selection]
-    elif selection < 10:
-      event = nyx.log.TOR_RUNLEVELS[selection - 5]
+    if selection < 10:
+      description = stem.control.event_description(nyx.log.TOR_RUNLEVELS[selection % 5])
     elif selection < (len(events) + 10):
-      event = events[selection - 10]
+      description = stem.control.event_description(events[selection - 10])
+    else:
+      description = None
 
-    if event:
-      subwindow.addstr_wrap(1, 1, stem.control.event_description(event), subwindow.width - 1, 1, GREEN, BOLD)
+    if description:
+      subwindow.addstr_wrap(1, 1, description, subwindow.width - 1, 1, GREEN, BOLD)
 
     subwindow.hline(1, 3, 78)
     subwindow._addch(0, 3, curses.ACS_LTEE)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits