[or-cvs] r23727: {arm} fix: basing man page filtering on tor's available config opt (in arm/trunk/src: . util)

Damian Johnson atagar1 at gmail.com
Sun Oct 31 03:44:47 UTC 2010


Author: atagar
Date: 2010-10-31 03:44:46 +0000 (Sun, 31 Oct 2010)
New Revision: 23727

Modified:
   arm/trunk/src/starter.py
   arm/trunk/src/util/torConfig.py
Log:
fix: basing man page filtering on tor's available config options (more accurate, and doesn't exclude single line config entries)



Modified: arm/trunk/src/starter.py
===================================================================
--- arm/trunk/src/starter.py	2010-10-31 03:07:06 UTC (rev 23726)
+++ arm/trunk/src/starter.py	2010-10-31 03:44:46 UTC (rev 23727)
@@ -254,15 +254,15 @@
   conn = TorCtl.TorCtl.connect(controlAddr, controlPort, authPassword)
   if conn == None: sys.exit(1)
   
-  # fetches descriptions for tor's configuration options
-  _loadConfigurationDescriptions()
-  
   # initializing the connection may require user input (for the password)
   # scewing the startup time results so this isn't counted
   initTime = time.time() - startTime
   controller = util.torTools.getConn()
   controller.init(conn)
   
+  # fetches descriptions for tor's configuration options
+  _loadConfigurationDescriptions()
+  
   interface.controller.startTorMonitor(time.time() - initTime, expandedEvents, param["startup.blindModeEnabled"])
   conn.close()
 

Modified: arm/trunk/src/util/torConfig.py
===================================================================
--- arm/trunk/src/util/torConfig.py	2010-10-31 03:07:06 UTC (rev 23726)
+++ arm/trunk/src/util/torConfig.py	2010-10-31 03:44:46 UTC (rev 23727)
@@ -110,6 +110,13 @@
     else:
       manCallResults = sysTools.call("man tor")
       
+      # Fetches all options available with this tor instance. This isn't
+      # vital, and the validOptions are left empty if the call fails.
+      conn, validOptions = torTools.getConn(), []
+      configOptionQuery = conn.getInfo("config/names").strip().split("\n")
+      if configOptionQuery:
+        validOptions = [line[:line.find(" ")].lower() for line in configOptionQuery]
+      
       lastOption, lastArg = None, None
       lastDescription = ""
       for line in manCallResults:
@@ -122,11 +129,12 @@
         isOptIndent = line.startswith(" " * MAN_OPT_INDENT) and line[MAN_OPT_INDENT] != " "
         
         if isOptIndent:
-          # Most lines with this indent that aren't config options won't have
-          # any description set at this point (not a perfect filter, but cuts
-          # down on the noise).
+          # Filters the line based on if the option is recognized by tor or
+          # not. This isn't necessary for arm, so if unable to make the check
+          # then we skip filtering (no loss, the map will just have some extra
+          # noise).
           strippedDescription = lastDescription.strip()
-          if lastOption and strippedDescription:
+          if lastOption and (not validOptions or lastOption.lower() in validOptions):
             CONFIG_DESCRIPTIONS[lastOption.lower()] = (lastArg, strippedDescription)
           lastDescription = ""
           



More information about the tor-commits mailing list