[tor-commits] [nyx/master] Stacktrace when showing connection panel's count dialog

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


commit 5969f127efef63cde02fcfe4b2617ee741b638c7
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Jun 8 08:33:08 2015 -0700

    Stacktrace when showing connection panel's count dialog
    
    Simple error when pressing 'c' on the connection panel...
    
      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 625, in start_nyx
          is_keystroke_consumed = panel_impl.handle_key(key)
        File "/home/atagar/Desktop/nyx/nyx/connections/conn_panel.py", line 316, in handle_key
          elif key.match('c') and self.is_clients_allowed():
        File "/home/atagar/Desktop/nyx/nyx/connections/conn_panel.py", line 218, in is_clients_allowed
          my_fingerprint = self.get_info('fingerprint', None)
      AttributeError: 'ConnectionPanel' object has no attribute 'get_info'
---
 nyx/connections/conn_panel.py |   33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/nyx/connections/conn_panel.py b/nyx/connections/conn_panel.py
index 786cf9c..290cc84 100644
--- a/nyx/connections/conn_panel.py
+++ b/nyx/connections/conn_panel.py
@@ -137,12 +137,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
     """
 
     self._is_tor_running = event_type in (State.INIT, State.RESET)
-
-    if self._is_tor_running:
-      self._halt_time = None
-    else:
-      self._halt_time = time.time()
-
+    self._halt_time = None if self._is_tor_running else time.time()
     self.redraw(True)
 
   def get_pause_time(self):
@@ -220,10 +215,10 @@ class ConnectionPanel(panel.Panel, threading.Thread):
     controller = tor_controller()
 
     my_flags = []
-    my_fingerprint = self.get_info('fingerprint', None)
+    my_fingerprint = controller.get_info('fingerprint', None)
 
     if my_fingerprint:
-      my_status_entry = self.controller.get_network_status(my_fingerprint)
+      my_status_entry = controller.get_network_status(my_fingerprint)
 
       if my_status_entry:
         my_flags = my_status_entry.flags
@@ -338,9 +333,9 @@ class ConnectionPanel(panel.Panel, threading.Thread):
     # run during nyx's interface initialization (otherwise there's a
     # noticeable pause before the first redraw).
 
-    self._cond.acquire()
-    self._cond.wait(0.2)
-    self._cond.release()
+    with self._cond:
+      self._cond.wait(0.2)
+
     self._update()             # populates initial entries
     self._resolve_apps(False)  # resolves initial applications
 
@@ -348,12 +343,9 @@ class ConnectionPanel(panel.Panel, threading.Thread):
       current_time = time.time()
 
       if self.is_paused() or not self._is_tor_running or current_time - last_draw < CONFIG['features.connection.refreshRate']:
-        self._cond.acquire()
-
-        if not self._halt:
-          self._cond.wait(0.2)
-
-        self._cond.release()
+        with self._cond:
+          if not self._halt:
+            self._cond.wait(0.2)
       else:
         # updates content if their's new results, otherwise just redraws
 
@@ -483,10 +475,9 @@ class ConnectionPanel(panel.Panel, threading.Thread):
     Halts further resolutions and terminates the thread.
     """
 
-    self._cond.acquire()
-    self._halt = True
-    self._cond.notifyAll()
-    self._cond.release()
+    with self._cond:
+      self._halt = True
+      self._cond.notifyAll()
 
   def _update(self):
     """





More information about the tor-commits mailing list