[tor-commits] [arm/master] Narrowing scope of start_arm()

atagar at torproject.org atagar at torproject.org
Sun Sep 22 00:59:33 UTC 2013


commit 6d262f4653a0705ed898c31a48ecbe044c325ddc
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Sep 21 17:22:46 2013 -0700

    Narrowing scope of start_arm()
    
    Rearranging things a bit so start_arm() now only concerns connection resolution
    and starting curses. We had a pretty bad regression where most of this
    connection related code actually wasn't getting executed at all - oops.
---
 arm/controller.py       |   15 +++------------
 arm/starter.py          |    8 ++++++++
 arm/util/connections.py |    2 +-
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/arm/controller.py b/arm/controller.py
index 68b9146..3623a2f 100644
--- a/arm/controller.py
+++ b/arm/controller.py
@@ -524,10 +524,11 @@ def start_arm(start_time):
     if controller.get_conf("DisableDebuggerAttachment", None) == "1":
       log.notice("Tor is preventing system utilities like netstat and lsof from working. This means that arm can't provide you with connection information. You can change this by adding 'DisableDebuggerAttachment 0' to your torrc and restarting tor. For more information see...\nhttps://trac.torproject.org/3313")
       connections.getResolver("tor").setPaused(True)
-
+    else:
       # Configures connection resoultions. This is paused/unpaused according to
       # if Tor's connected or not.
-      torTools.getConn().addStatusListener(connResetListener)
+
+      controller.add_status_listener(connResetListener)
 
       tor_pid = controller.get_pid(None)
 
@@ -544,16 +545,6 @@ def start_arm(start_time):
         # it to be paused
         connections.getResolver("tor").setPaused(not controller.is_alive())
 
-      # hack to display a better (arm specific) notice if all resolvers fail
-      connections.RESOLVER_FINAL_FAILURE_MSG = "We were unable to use any of your system's resolvers to get tor's connections. This is fine, but means that the connections page will be empty. This is usually permissions related so if you would like to fix this then run arm with the same user as tor (ie, \"sudo -u <tor user> arm\")."
-
-  # provides a notice about any event types tor supports but arm doesn't
-  missing_event_types = arm.logPanel.getMissingEventTypes()
-
-  if missing_event_types:
-    plural_label = "s" if len(missing_event_types) > 1 else ""
-    log.info("arm doesn't recognize the following event type%s: %s (log 'UNKNOWN' events to see them)" % (plural_label, ", ".join(missing_event_types)))
-
   try:
     curses.wrapper(drawTorMonitor, start_time)
   except UnboundLocalError as exc:
diff --git a/arm/starter.py b/arm/starter.py
index 0e4ca9e..95dbc46 100644
--- a/arm/starter.py
+++ b/arm/starter.py
@@ -387,6 +387,14 @@ def main():
   if arm.util.uiTools.isUnicodeAvailable():
     locale.setlocale(locale.LC_ALL, "")
 
+  # provides a notice about any event types tor supports but arm doesn't
+
+  missing_event_types = arm.logPanel.getMissingEventTypes()
+
+  if missing_event_types:
+    plural_label = "s" if len(missing_event_types) > 1 else ""
+    stem.util.log.info("arm doesn't recognize the following event type%s: %s (log 'UNKNOWN' events to see them)" % (plural_label, ", ".join(missing_event_types)))
+
   arm.controller.start_arm(start_time)
 
 if __name__ == '__main__':
diff --git a/arm/util/connections.py b/arm/util/connections.py
index 423a555..38fdf70 100644
--- a/arm/util/connections.py
+++ b/arm/util/connections.py
@@ -74,7 +74,7 @@ RUN_BSD_PROCSTAT = "procstat -f %s"
 RESOLVERS = []                      # connection resolvers available via the singleton constructor
 RESOLVER_FAILURE_TOLERANCE = 3      # number of subsequent failures before moving on to another resolver
 RESOLVER_SERIAL_FAILURE_MSG = "Unable to query connections with %s, trying %s"
-RESOLVER_FINAL_FAILURE_MSG = "All connection resolvers failed"
+RESOLVER_FINAL_FAILURE_MSG = "We were unable to use any of your system's resolvers to get tor's connections. This is fine, but means that the connections page will be empty. This is usually permissions related so if you would like to fix this then run arm with the same user as tor (ie, \"sudo -u <tor user> arm\")."
 
 def conf_handler(key, value):
   if key.startswith("port.label."):





More information about the tor-commits mailing list