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

[tor-commits] [nyx/master] Drop conn_reset_listener()



commit 16dc6d613c2ad7f9a982f351ff4a746d58f6deb3
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Wed Feb 10 19:05:06 2016 -0800

    Drop conn_reset_listener()
    
    Moving the last remnents of the controller's status listener into other spots.
---
 nyx/controller.py        | 12 ------------
 nyx/header_panel.py      |  5 ++++-
 nyx/settings/strings.cfg |  1 +
 nyx/util/tracker.py      |  3 +++
 4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/nyx/controller.py b/nyx/controller.py
index fcc6239..07cab4d 100644
--- a/nyx/controller.py
+++ b/nyx/controller.py
@@ -3,7 +3,6 @@ Main interface loop for nyx, periodically redrawing the screen and issuing
 user input to the proper panels.
 """
 
-import os
 import time
 import curses
 import threading
@@ -20,7 +19,6 @@ import nyx.util.tracker
 
 import stem
 
-from stem.control import State
 from stem.util import conf, log
 
 from nyx.util import panel, tor_controller, ui_tools
@@ -111,11 +109,6 @@ def init_controller(stdscr, start_time):
   if CONFIG['features.panels.show.connection']:
     page_panels.append([nyx.connection_panel.ConnectionPanel(stdscr)])
 
-    controller = tor_controller()
-    controller.add_status_listener(conn_reset_listener)
-    resolver = nyx.util.tracker.get_connection_tracker()
-    log.info('Operating System: %s, Connection Resolvers: %s' % (os.uname()[0], ', '.join(resolver._resolvers)))
-
   # third page: config
 
   if CONFIG['features.panels.show.config']:
@@ -430,11 +423,6 @@ def heartbeat_check(is_unresponsive):
   return is_unresponsive
 
 
-def conn_reset_listener(controller, event_type, _):
-  if event_type == State.CLOSED:
-    log.notice('Tor control port closed')
-
-
 def start_nyx(stdscr):
   """
   Main draw loop context.
diff --git a/nyx/header_panel.py b/nyx/header_panel.py
index 4eb0a84..4a0841e 100644
--- a/nyx/header_panel.py
+++ b/nyx/header_panel.py
@@ -15,7 +15,7 @@ import stem
 import nyx.controller
 import nyx.popups
 
-from stem.control import Listener
+from stem.control import Listener, State
 from stem.util import conf, log, proc, str_tools, system
 from nyx.util import msg, tor_controller, panel, tracker
 
@@ -370,6 +370,9 @@ class HeaderPanel(panel.Panel, threading.Thread):
   def reset_listener(self, controller, event_type, _):
     self._update()
 
+    if event_type == State.CLOSED:
+      log.notice('Tor control port closed')
+
   def _update(self):
     previous_height = self.get_height()
     self._vals = get_sampling(self._vals)
diff --git a/nyx/settings/strings.cfg b/nyx/settings/strings.cfg
index bfe375f..f669e43 100644
--- a/nyx/settings/strings.cfg
+++ b/nyx/settings/strings.cfg
@@ -37,6 +37,7 @@ msg.setup.unknown_event_types nyx doesn't recognize the following event types: {
 msg.setup.color_support_available Terminal color support detected and enabled
 msg.setup.color_support_unavailable Terminal color support unavailable
 
+msg.tracker.available_resolvers Operating System: {os}, Connection Resolvers: {resolvers}
 msg.tracker.abort_getting_resources Failed three attempts to get process resource usage from {resolver}, {response} ({exc})
 msg.tracker.abort_getting_port_usage Failed three attempts to determine the process using active ports ({exc})
 msg.tracker.lookup_rate_increased connection lookup time increasing to {seconds} seconds per call
diff --git a/nyx/util/tracker.py b/nyx/util/tracker.py
index 8aa1181..2b2b155 100644
--- a/nyx/util/tracker.py
+++ b/nyx/util/tracker.py
@@ -47,6 +47,7 @@ Background tasks for gathering information about the tor process.
 """
 
 import collections
+import os
 import time
 import threading
 
@@ -501,6 +502,8 @@ class ConnectionTracker(Daemon):
     else:
       self._resolvers = [CustomResolver.INFERENCE]
 
+    log.info('tracker.available_resolvers', os = os.uname()[0], resolvers = ', '.join(self._resolvers))
+
   def _task(self, process_pid, process_name):
     if self._custom_resolver:
       resolver = self._custom_resolver



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