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

[or-cvs] r24038: {arm} Displaying a short summary describing configuration options (in arm/trunk: . src src/interface src/util)



Author: atagar
Date: 2011-01-05 17:49:26 +0000 (Wed, 05 Jan 2011)
New Revision: 24038

Modified:
   arm/trunk/TODO
   arm/trunk/src/interface/configPanel.py
   arm/trunk/src/settings.cfg
   arm/trunk/src/util/torConfig.py
Log:
Displaying a short summary describing configuration options (if a description is available). Thus far I have summaries for a bit over a dozen of the general options (I'll finish off the general section, and leave the rest as a TODO for now). Idea for impoving the config panel came from Sebastian.



Modified: arm/trunk/TODO
===================================================================
--- arm/trunk/TODO	2011-01-05 11:23:51 UTC (rev 24037)
+++ arm/trunk/TODO	2011-01-05 17:49:26 UTC (rev 24038)
@@ -88,6 +88,9 @@
 
 - Bugs
   * The default resolver isn't configurable.
+  * The arm header panel doesn't properly reflect when the ip address
+    changes. This provides a notice event saying:
+    "Our IP Address has changed from X to Y; rebuilding descriptor (source Z)."
   * The cpu usage spikes for scrollable content when the key's held. Try
     coalescing the events.
   * The manpage layout is system dependent, so the scraper needs to be more

Modified: arm/trunk/src/interface/configPanel.py
===================================================================
--- arm/trunk/src/interface/configPanel.py	2011-01-05 11:23:51 UTC (rev 24037)
+++ arm/trunk/src/interface/configPanel.py	2011-01-05 17:49:26 UTC (rev 24038)
@@ -30,13 +30,14 @@
                   torConfig.UNKNOWN: "white"}
 
 # attributes of a ConfigEntry
-FIELD_CATEGORY, FIELD_OPTION, FIELD_VALUE, FIELD_TYPE, FIELD_ARG_USAGE, FIELD_DESCRIPTION, FIELD_MAN_ENTRY, FIELD_IS_DEFAULT = range(8)
+FIELD_CATEGORY, FIELD_OPTION, FIELD_VALUE, FIELD_TYPE, FIELD_ARG_USAGE, FIELD_SUMMARY, FIELD_DESCRIPTION, FIELD_MAN_ENTRY, FIELD_IS_DEFAULT = range(9)
 DEFAULT_SORT_ORDER = (FIELD_CATEGORY, FIELD_MAN_ENTRY, FIELD_IS_DEFAULT)
 FIELD_ATTR = {FIELD_CATEGORY: ("Category", "red"),
               FIELD_OPTION: ("Option Name", "blue"),
               FIELD_VALUE: ("Value", "cyan"),
               FIELD_TYPE: ("Arg Type", "green"),
               FIELD_ARG_USAGE: ("Arg Usage", "yellow"),
+              FIELD_SUMMARY: ("Summary", "green"),
               FIELD_DESCRIPTION: ("Description", "white"),
               FIELD_MAN_ENTRY: ("Man Page Entry", "blue"),
               FIELD_IS_DEFAULT: ("Is Default", "magenta")}
@@ -46,7 +47,7 @@
   Configuration option in the panel.
   """
   
-  def __init__(self, option, type, isDefault, manEntry):
+  def __init__(self, option, type, isDefault, summary, manEntry):
     self.fields = {}
     self.fields[FIELD_OPTION] = option
     self.fields[FIELD_TYPE] = type
@@ -62,6 +63,8 @@
       self.fields[FIELD_CATEGORY] = torConfig.UNKNOWN
       self.fields[FIELD_ARG_USAGE] = ""
       self.fields[FIELD_DESCRIPTION] = ""
+    
+    self.fields[FIELD_SUMMARY] = summary if summary != None else self.fields[FIELD_DESCRIPTION]
   
   def get(self, field):
     """
@@ -144,8 +147,9 @@
         elif not self._config["features.config.state.showVirtualOptions"] and confType == "Virtual":
           continue
         
+        summary = torConfig.getConfigSummary(confOption)
         manEntry = torConfig.getConfigDescription(confOption)
-        self.confContents.append(ConfigEntry(confOption, confType, not confOption in customOptions, manEntry))
+        self.confContents.append(ConfigEntry(confOption, confType, not confOption in customOptions, summary, manEntry))
       
       self.setSortOrder() # initial sorting of the contents
     elif self.configType == ARM_STATE:
@@ -227,16 +231,14 @@
       
       optionLabel = uiTools.cropStr(entry.get(FIELD_OPTION), optionWidth)
       valueLabel = uiTools.cropStr(entry.get(FIELD_VALUE), valueWidth)
+      summaryLabel = uiTools.cropStr(entry.get(FIELD_SUMMARY), descriptionWidth, None)
       
-      # ends description at the first newline
-      descriptionLabel = uiTools.cropStr(entry.get(FIELD_DESCRIPTION).split("\n")[0], descriptionWidth, None)
-      
       lineFormat = curses.A_NORMAL if entry.get(FIELD_IS_DEFAULT) else curses.A_BOLD
       if entry.get(FIELD_CATEGORY): lineFormat |= uiTools.getColor(CATEGORY_COLOR[entry.get(FIELD_CATEGORY)])
       if entry == cursorSelection: lineFormat |= curses.A_STANDOUT
       
       lineTextLayout = "%%-%is %%-%is %%-%is" % (optionWidth, valueWidth, descriptionWidth)
-      lineText = lineTextLayout % (optionLabel, valueLabel, descriptionLabel)
+      lineText = lineTextLayout % (optionLabel, valueLabel, summaryLabel)
       self.addstr(drawLine, scrollOffset, lineText, lineFormat)
       
       if drawLine >= height: break

Modified: arm/trunk/src/settings.cfg
===================================================================
--- arm/trunk/src/settings.cfg	2011-01-05 11:23:51 UTC (rev 24037)
+++ arm/trunk/src/settings.cfg	2011-01-05 17:49:26 UTC (rev 24038)
@@ -1,3 +1,23 @@
+# Summary descriptions for Tor configuration options
+config.summary.BandwidthRate Average bandwidth usage limit
+config.summary.BandwidthBurst Maximum bandwidth usage limit
+config.summary.MaxAdvertisedBandwidth Limit for the bandwidth we advertise as being available for relaying
+config.summary.RelayBandwidthRate Average bandwidth usage limit for relaying
+config.summary.RelayBandwidthBurst Maximum bandwidth usage limit for relaying
+config.summary.PerConnBWRate Average relayed bandwidth limit per connection
+config.summary.PerConnBWBurst Maximum relayed bandwidth limit per connection
+config.summary.ConLimit Minimum number of file descriptors for Tor to start
+config.summary.ConstrainedSockets Shrinks sockets to ConstrainedSockSize
+config.summary.ConstrainedSockSize Limit for the received and transmit buffers of sockets
+config.summary.ControlPort Port providing access to tor controllers (arm, vidalia, etc)
+config.summary.ControlListenAddress Address providing controller access
+config.summary.ControlSocket Socket providing controller access
+config.summary.HashedControlPassword Hash of the password for authenticating to the control port
+config.summary.CookieAuthentication If set, authenticates controllers via a cookie
+config.summary.CookieAuthFile Location of the authentication cookie
+config.summary.CookieAuthFileGroupReadable Group read permissions for the authentication cookie
+config.summary.DataDirectory Location for storing runtime data (state, keys, etc)
+
 # Snippets from common log messages
 # These are static bits of log messages, used to determine when entries with
 # dynamic content (hostnames, numbers, etc) are the same. If this matches the

Modified: arm/trunk/src/util/torConfig.py
===================================================================
--- arm/trunk/src/util/torConfig.py	2011-01-05 11:23:51 UTC (rev 24037)
+++ arm/trunk/src/util/torConfig.py	2011-01-05 17:49:26 UTC (rev 24038)
@@ -53,6 +53,11 @@
 def loadConfig(config):
   CONFIG["torrc.alias"] = config.get("torrc.alias", {})
   
+  # fetches any config.summary.* values
+  for configKey in config.getKeys():
+    if configKey.startswith("config.summary."):
+      CONFIG[configKey.lower()] = config.get(configKey)
+  
   # all the torrc.label.* values are comma separated lists
   for configKey in CONFIG.keys():
     if configKey.startswith("torrc.label."):
@@ -270,6 +275,17 @@
   outputFile.close()
   CONFIG_DESCRIPTIONS_LOCK.release()
 
+def getConfigSummary(option):
+  """
+  Provides a short summary description of th configuration option. If none is
+  known then this proivdes None.
+  
+  Arguments:
+    option - tor config option
+  """
+  
+  return CONFIG.get("config.summary.%s" % option.lower())
+
 def getConfigDescription(option):
   """
   Provides ManPageEntry instances populated with information fetched from the