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

[or-cvs] r23722: {arm} Including descriptions for the config options on the setting (in arm/trunk: . src src/interface src/util)



Author: atagar
Date: 2010-10-29 17:10:00 +0000 (Fri, 29 Oct 2010)
New Revision: 23722

Modified:
   arm/trunk/TODO
   arm/trunk/src/interface/configStatePanel.py
   arm/trunk/src/starter.py
   arm/trunk/src/util/torConfig.py
Log:
Including descriptions for the config options on the settings panel.

This is adding about 200ms to arm's startup time. I'll try to improve this next (nickm suggested saving cached results to disk, which should take care of this for subsiquent runs).



Modified: arm/trunk/TODO
===================================================================
--- arm/trunk/TODO	2010-10-29 16:09:23 UTC (rev 23721)
+++ arm/trunk/TODO	2010-10-29 17:10:00 UTC (rev 23722)
@@ -60,6 +60,10 @@
             - http://www.linuxjournal.com/article/5737
 
 - Bugs
+  * The log panel gets cripplingly slow if the log grows to be even moderately
+    large (200 entries or so). This is most likely due to the hack for
+    dynamically determining the content height. Check if a solution like the
+    one for the confFilePanel will work.
   * path for sample armrc in man page is wrong
   * when in client mode and tor stops the header panel doesn't say so
   * util are assuming that tor is running under the default command name

Modified: arm/trunk/src/interface/configStatePanel.py
===================================================================
--- arm/trunk/src/interface/configStatePanel.py	2010-10-29 16:09:23 UTC (rev 23721)
+++ arm/trunk/src/interface/configStatePanel.py	2010-10-29 17:10:00 UTC (rev 23722)
@@ -6,7 +6,7 @@
 import curses
 import threading
 
-from util import conf, panel, torTools, uiTools
+from util import conf, panel, torTools, torConfig, uiTools
 
 DEFAULT_CONFIG = {"features.config.state.colWidth.option": 25,
                   "features.config.state.colWidth.value": 15}
@@ -81,7 +81,12 @@
         # UseEntryGuards Boolean
         line = configOptionQuery[lineNum]
         confOption, confType = line.strip().split(" ", 1)
-        self.confContents.append(ConfigEntry(confOption, confType, "", not confOption in setOptions))
+        
+        confDescription = ""
+        descriptionComp = torConfig.getConfigDescription(confOption)
+        if descriptionComp: confDescription = descriptionComp[1]
+        
+        self.confContents.append(ConfigEntry(confOption, confType, confDescription, not confOption in setOptions))
     elif self.configType == ARM_STATE:
       # loaded via the conf utility
       armConf = conf.getConfig("arm")
@@ -134,11 +139,20 @@
       valueLabel = uiTools.cropStr(entryToValues[entry], valueColWidth)
       
       lineFormat = uiTools.getColor("green") if entry.isDefault else curses.A_BOLD | uiTools.getColor("yellow")
+      xOffset = scrollOffset
       
-      self.addstr(drawLine, scrollOffset, optionLabel, lineFormat)
-      self.addstr(drawLine, scrollOffset + optionColWidth + 1, valueLabel, lineFormat)
-      self.addstr(drawLine, scrollOffset + optionColWidth + valueColWidth + 2, entry.type, lineFormat)
+      self.addstr(drawLine, xOffset, optionLabel, lineFormat)
+      xOffset += optionColWidth + 1
       
+      self.addstr(drawLine, xOffset, valueLabel, lineFormat)
+      xOffset += valueColWidth + 1
+      
+      self.addstr(drawLine, xOffset, entry.type, lineFormat)
+      xOffset += typeColWidth + 1
+      
+      descriptionLabel = uiTools.cropStr(entry.description, width - xOffset)
+      self.addstr(drawLine, xOffset, descriptionLabel, lineFormat)
+      
       if drawLine >= height: break
     
     self.valsLock.release()

Modified: arm/trunk/src/starter.py
===================================================================
--- arm/trunk/src/starter.py	2010-10-29 16:09:23 UTC (rev 23721)
+++ arm/trunk/src/starter.py	2010-10-29 17:10:00 UTC (rev 23722)
@@ -186,6 +186,18 @@
   conn = TorCtl.TorCtl.connect(controlAddr, controlPort, authPassword)
   if conn == None: sys.exit(1)
   
+  # It is important that this is loaded before entering the curses context,
+  # otherwise the man call pegs the cpu for around a minute (I'm not sure
+  # why... curses must mess the terminal in a way that's important to man).
+  
+  # TODO: Moving into an async call isn't helping with the startup time. Next,
+  # try caching the parsed results to disk (idea by nickm).
+  #import threading
+  #t = threading.Thread(target = util.torConfig.loadOptionDescriptions)
+  #t.setDaemon(True)
+  #t.start()
+  util.torConfig.loadOptionDescriptions()
+  
   # initializing the connection may require user input (for the password)
   # scewing the startup time results so this isn't counted
   initTime = time.time() - startTime

Modified: arm/trunk/src/util/torConfig.py
===================================================================
--- arm/trunk/src/util/torConfig.py	2010-10-29 16:09:23 UTC (rev 23721)
+++ arm/trunk/src/util/torConfig.py	2010-10-29 17:10:00 UTC (rev 23722)
@@ -117,17 +117,6 @@
   CONFIG_DESCRIPTIONS_LOCK.release()
   if raisedExc: raise raisedExc
 
-def isConfigDescriptionAvailable(option):
-  """
-  Returns if a description for the given configuration option has been loaded
-  or not.
-  
-  Arguments:
-    option - tor config option
-  """
-  
-  return option in CONFIG_DESCRIPTIONS
-
 def getConfigDescription(option):
   """
   Provides a tuple with arguments and description for the given tor