[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [nyx/master] Fix menu's 'exit' option
commit 594e96c389d05a81f658f766fe2c88bab1e763f8
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Thu Apr 30 08:29:04 2015 -0700
Fix menu's 'exit' option
Earlier change that dropped the quit method broke our menu, causing nyx to
crash with the following when you bring it up...
Traceback (most recent call last):
File "./run_nyx", line 60, in <module>
main()
File "./run_nyx", line 17, 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 590, in start_nyx
nyx.menu.menu.show_menu()
File "/home/atagar/Desktop/nyx/nyx/menu/menu.py", line 90, in show_menu
menu = nyx.menu.actions.make_menu()
File "/home/atagar/Desktop/nyx/nyx/menu/actions.py", line 31, in make_menu
base_menu.add(make_actions_menu())
File "/home/atagar/Desktop/nyx/nyx/menu/actions.py", line 81, in make_actions_menu
actions_menu.add(nyx.menu.item.MenuItem('Exit', control.quit))
AttributeError: Controller instance has no attribute 'quit'
---
nyx/controller.py | 6 +++++-
nyx/log_panel.py | 6 +-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/nyx/controller.py b/nyx/controller.py
index 6225038..77b2037 100644
--- a/nyx/controller.py
+++ b/nyx/controller.py
@@ -208,6 +208,7 @@ class Controller:
page_panels - list of pages, each being a list of the panels on it
"""
+ self.quit_signal = False
self._screen = stdscr
self._sticky_panels = sticky_panels
self._page_panels = page_panels
@@ -465,6 +466,9 @@ class Controller:
return data_dir
+ def quit(self):
+ self.quit_signal = True
+
def heartbeat_check(is_unresponsive):
"""
@@ -558,7 +562,7 @@ def start_nyx(stdscr):
override_key = None # uses this rather than waiting on user input
is_unresponsive = False # flag for heartbeat responsiveness check
- while True:
+ while not control.quit_signal:
display_panels = control.get_display_panels()
is_unresponsive = heartbeat_check(is_unresponsive)
diff --git a/nyx/log_panel.py b/nyx/log_panel.py
index e1465ab..4a7e6de 100644
--- a/nyx/log_panel.py
+++ b/nyx/log_panel.py
@@ -369,9 +369,7 @@ class LogPanel(panel.Panel, threading.Thread):
# does all activity under a curses lock to prevent redraws when adding
# new filters
- panel.CURSES_LOCK.acquire()
-
- try:
+ with CURSES_LOCK:
selection = nyx.popups.show_menu('Log Filter:', options, old_selection)
# applies new setting
@@ -383,8 +381,6 @@ class LogPanel(panel.Panel, threading.Thread):
self.show_filter_prompt()
elif selection != -1:
self.make_filter_selection(self.filter_options[selection - 1])
- finally:
- panel.CURSES_LOCK.release()
if len(self.filter_options) > MAX_REGEX_FILTERS:
del self.filter_options[MAX_REGEX_FILTERS:]
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits