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

[or-cvs] r22496: {arm} change: providing notice for unrecognized armrc values (in arm/trunk: . interface util)



Author: atagar
Date: 2010-06-09 15:46:48 +0000 (Wed, 09 Jun 2010)
New Revision: 22496

Modified:
   arm/trunk/TODO
   arm/trunk/armrc.sample
   arm/trunk/interface/controller.py
   arm/trunk/interface/headerPanel.py
   arm/trunk/util/conf.py
Log:
change: providing notice for unrecognized armrc values



Modified: arm/trunk/TODO
===================================================================
--- arm/trunk/TODO	2010-06-09 01:04:12 UTC (rev 22495)
+++ arm/trunk/TODO	2010-06-09 15:46:48 UTC (rev 22496)
@@ -48,11 +48,7 @@
   * provide performance ARM-DEBUG events
       Help with diagnosing performance bottlenecks. This is pending the
       codebase revisions to figure out the low hanging fruit for caching.
-  * wrapper for user config settings
-    * <done> user customizable armrc
-    * make various interface update rates setable via the config
-    * log messages about loading armrc (info level indicating if armrc was
-        found, etc)
+  * <done> user customizable armrc
   * tor util
     * <done> wrapper for accessing torctl
     * allow arm to resume after restarting tor (attaching to a new torctl
@@ -115,6 +111,8 @@
     * connections aren't cleared when control port closes
 
 - Features / Site
+  * page with details on client circuits, attempting to detect details like
+      country, ISP, latency, exit policy for the circuit, traffic, etc
   * attempt to clear controller password from memory
       http://www.codexon.com/posts/clearing-passwords-in-memory-with-python
   * try/catch check when starting for curses support?

Modified: arm/trunk/armrc.sample
===================================================================
--- arm/trunk/armrc.sample	2010-06-09 01:04:12 UTC (rev 22495)
+++ arm/trunk/armrc.sample	2010-06-09 15:46:48 UTC (rev 22496)
@@ -1,4 +1,4 @@
-# default startup options
+# startup options
 startup.controlPassword
 startup.interface.ipAddress 127.0.0.1
 startup.interface.port 9051
@@ -31,6 +31,7 @@
 
 # runlevels at which to log arm related events
 log.configEntryNotFound NONE
+log.configEntryUndefined NOTICE
 log.configEntryTypeError NOTICE
 log.sysCallMade DEBUG
 log.sysCallCached NONE

Modified: arm/trunk/interface/controller.py
===================================================================
--- arm/trunk/interface/controller.py	2010-06-09 01:04:12 UTC (rev 22495)
+++ arm/trunk/interface/controller.py	2010-06-09 15:46:48 UTC (rev 22496)
@@ -22,7 +22,7 @@
 import descriptorPopup
 import fileDescriptorPopup
 
-from util import log, connections, hostnames, panel, sysTools, torTools, uiTools
+from util import conf, log, connections, hostnames, panel, sysTools, torTools, uiTools
 import bandwidthMonitor
 import cpuMemMonitor
 import connCountMonitor
@@ -42,6 +42,9 @@
   ["torrc"]]
 PAUSEABLE = ["header", "graph", "log", "conn"]
 
+# user customizable parameters
+CONFIG = {"log.configEntryUndefined": log.NOTICE}
+
 class ControlPanel(panel.Panel):
   """ Draws single line label for interface controls. """
   
@@ -407,6 +410,13 @@
   regexFilters = []             # previously used log regex filters
   panels["popup"].redraw()      # hack to make sure popup has a window instance (not entirely sure why...)
   
+  # provides notice about any unused config keys
+  config = conf.getConfig("arm")
+  config.update(CONFIG)
+  
+  for key in config.getUnusedKeys():
+    log.log(CONFIG["log.configEntryUndefined"], "config entry '%s' is unrecognized" % key)
+  
   while True:
     # tried only refreshing when the screen was resized but it caused a
     # noticeable lag when resizing and didn't have an appreciable effect

Modified: arm/trunk/interface/headerPanel.py
===================================================================
--- arm/trunk/interface/headerPanel.py	2010-06-09 01:04:12 UTC (rev 22495)
+++ arm/trunk/interface/headerPanel.py	2010-06-09 15:46:48 UTC (rev 22496)
@@ -21,8 +21,7 @@
 from util import conf, panel, sysTools, torTools, uiTools
 
 # seconds between querying information
-DEFAULT_UPDATE_RATE = 5
-UPDATE_RATE_CFG = "queries.ps.rate"
+UPDATE_RATE_CFG = ("queries.ps.rate", 5)
 
 # minimum width for which panel attempts to double up contents (two columns to
 # better use screen real estate)
@@ -54,7 +53,7 @@
     threading.Thread.__init__(self)
     self.setDaemon(True)
     
-    self._updateRate = conf.getConfig("arm").get(UPDATE_RATE_CFG, DEFAULT_UPDATE_RATE, 1)
+    self._updateRate = conf.getConfig("arm").get(UPDATE_RATE_CFG[0], UPDATE_RATE_CFG[1], 1)
     self._isTorConnected = True
     self._lastUpdate = -1       # time the content was last revised
     self._isLastDrawWide = False

Modified: arm/trunk/util/conf.py
===================================================================
--- arm/trunk/util/conf.py	2010-06-09 01:04:12 UTC (rev 22495)
+++ arm/trunk/util/conf.py	2010-06-09 15:46:48 UTC (rev 22496)
@@ -59,9 +59,10 @@
     self.path = None        # path to the associated configuation file
     self.contents = {}      # configuration key/value pairs
     self.contentsLock = threading.RLock()
+    self.requestedKeys = set()
     self.rawContents = []   # raw contents read from configuration file
   
-  def getSimple(self, key, default=None):
+  def getStr(self, key, default=None):
     """
     This provides the currently value associated with a given key. If no such
     key exists then this provides the default.
@@ -73,7 +74,9 @@
     
     self.contentsLock.acquire()
     
-    if key in self.contents: val = self.contents[key]
+    if key in self.contents:
+      val = self.contents[key]
+      self.requestedKeys.add(key)
     else:
       msg = "config entry '%s' not found, defaulting to '%s'" % (key, str(default))
       log.log(CONFIG["log.configEntryNotFound"], msg)
@@ -101,11 +104,16 @@
     """
     
     callDefault = log.runlevelToStr(default) if key.startswith("log.") else default
-    val = self.getSimple(key, callDefault)
+    val = self.getStr(key, callDefault)
     if val == default: return val
     
     if key.startswith("log."):
-      val = log.strToRunlevel(val)
+      if val.lower() in ("none", "debug", "info", "notice", "warn", "err"):
+        val = log.strToRunlevel(val)
+      else:
+        msg = "config entry '%s' is expected to be a runlevel, defaulting to '%s'" % (key, callDefault)
+        log.log(CONFIG["log.configEntryTypeError"], msg)
+        val = default
     elif isinstance(default, bool):
       if val.lower() == "true": val = True
       elif val.lower() == "false": val = False
@@ -146,6 +154,20 @@
     for entry in confMappings.keys():
       confMappings[entry] = self.get(entry, confMappings[entry])
   
+  def getKeys(self):
+    """
+    Provides all keys in the currently loaded configuration.
+    """
+    
+    return self.contents.keys()
+  
+  def getUnusedKeys(self):
+    """
+    Provides the set of keys that have never been requested.
+    """
+    
+    return set(self.getKeys()).difference(self.requestedKeys)
+  
   def set(self, key, value):
     """
     Stores the given configuration value.