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

[tor-commits] [arm/master] Using stem's get_info() method



commit 4eea8d3191d5fc933bf452c0f0b4d0f41614e51d
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Dec 11 19:52:40 2012 -0800

    Using stem's get_info() method
    
    Stem's get_info() method is very similar to our own, the most notable
    difference being that it doesn't have a 'suppressExc' argument. Instead if it
    gets a default then exceptions are suppressed, and if it doesn't then they're
    raised. This is far more intuitive usage than ours, but means that our callers
    need to add the 'None' value we were defaulting to before.
---
 src/cli/configPanel.py             |    2 +-
 src/cli/connections/connEntry.py   |    2 +-
 src/cli/connections/connPanel.py   |    2 +-
 src/cli/controller.py              |    2 +-
 src/cli/graphing/bandwidthStats.py |   16 +++---
 src/cli/logPanel.py                |    2 +-
 src/starter.py                     |    2 +-
 src/util/torConfig.py              |    8 +-
 src/util/torInterpretor.py         |   20 +++---
 src/util/torTools.py               |  108 +++++++++++-------------------------
 10 files changed, 61 insertions(+), 103 deletions(-)

diff --git a/src/cli/configPanel.py b/src/cli/configPanel.py
index 31118c9..a73f2a8 100644
--- a/src/cli/configPanel.py
+++ b/src/cli/configPanel.py
@@ -221,7 +221,7 @@ class ConfigPanel(panel.Panel):
     if self.configType == State.TOR:
       conn, configOptionLines = torTools.getConn(), []
       customOptions = torConfig.getCustomOptions()
-      configOptionQuery = conn.getInfo("config/names")
+      configOptionQuery = conn.getInfo("config/names", None)
       
       if configOptionQuery:
         configOptionLines = configOptionQuery.strip().split("\n")
diff --git a/src/cli/connections/connEntry.py b/src/cli/connections/connEntry.py
index 02f7069..f7f08c3 100644
--- a/src/cli/connections/connEntry.py
+++ b/src/cli/connections/connEntry.py
@@ -202,7 +202,7 @@ class ConnectionLine(entries.ConnectionPanelLine):
     
     # overwrite the local fingerprint with ours
     conn = torTools.getConn()
-    self.local.fingerprintOverwrite = conn.getInfo("fingerprint")
+    self.local.fingerprintOverwrite = conn.getInfo("fingerprint", None)
     
     # True if the connection has matched the properties of a client/directory
     # connection every time we've checked. The criteria we check is...
diff --git a/src/cli/connections/connPanel.py b/src/cli/connections/connPanel.py
index cf7823a..927826b 100644
--- a/src/cli/connections/connPanel.py
+++ b/src/cli/connections/connPanel.py
@@ -77,7 +77,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
     # last day's clients.
     
     conn = torTools.getConn()
-    bridgeClients = conn.getInfo("status/clients-seen")
+    bridgeClients = conn.getInfo("status/clients-seen", None)
     
     if bridgeClients:
       # Response has a couple arguments...
diff --git a/src/cli/controller.py b/src/cli/controller.py
index c72375b..e79ca5a 100644
--- a/src/cli/controller.py
+++ b/src/cli/controller.py
@@ -510,7 +510,7 @@ class TorManager:
       conn - controller instance to be checked
     """
     
-    return conn.getInfo("config-file") == self.getTorrcPath()
+    return conn.getInfo("config-file", None) == self.getTorrcPath()
   
   def startManagedInstance(self):
     """
diff --git a/src/cli/graphing/bandwidthStats.py b/src/cli/graphing/bandwidthStats.py
index 9782d9f..390ad16 100644
--- a/src/cli/graphing/bandwidthStats.py
+++ b/src/cli/graphing/bandwidthStats.py
@@ -69,11 +69,11 @@ class BandwidthStats(graphPanel.GraphStats):
     self.initialPrimaryTotal = 0
     self.initialSecondaryTotal = 0
     
-    readTotal = conn.getInfo("traffic/read")
+    readTotal = conn.getInfo("traffic/read", None)
     if readTotal and readTotal.isdigit():
       self.initialPrimaryTotal = int(readTotal) / 1024 # Bytes -> KB
     
-    writeTotal = conn.getInfo("traffic/written")
+    writeTotal = conn.getInfo("traffic/written", None)
     if writeTotal and writeTotal.isdigit():
       self.initialSecondaryTotal = int(writeTotal) / 1024 # Bytes -> KB
   
@@ -94,7 +94,7 @@ class BandwidthStats(graphPanel.GraphStats):
     self.new_desc_event(None) # updates title params
     
     if eventType in (torTools.State.INIT, torTools.State.RESET) and self._config["features.graph.bw.accounting.show"]:
-      isAccountingEnabled = conn.getInfo('accounting/enabled') == '1'
+      isAccountingEnabled = conn.getInfo('accounting/enabled', None) == '1'
       
       if isAccountingEnabled != self.isAccounting:
         self.isAccounting = isAccountingEnabled
@@ -335,7 +335,7 @@ class BandwidthStats(graphPanel.GraphStats):
     conn = torTools.getConn()
     if not conn.isAlive(): return # keep old values
     
-    myFingerprint = conn.getInfo("fingerprint")
+    myFingerprint = conn.getInfo("fingerprint", None)
     if not self._titleStats or not myFingerprint or (event and myFingerprint in event.idlist):
       stats = []
       bwRate = conn.getMyBandwidthRate()
@@ -386,10 +386,10 @@ class BandwidthStats(graphPanel.GraphStats):
     
     conn = torTools.getConn()
     queried = dict([(arg, "") for arg in ACCOUNTING_ARGS])
-    queried["status"] = conn.getInfo("accounting/hibernating")
+    queried["status"] = conn.getInfo("accounting/hibernating", None)
     
     # provides a nicely formatted reset time
-    endInterval = conn.getInfo("accounting/interval-end")
+    endInterval = conn.getInfo("accounting/interval-end", None)
     if endInterval:
       # converts from gmt to local with respect to DST
       if time.localtime()[8]: tz_offset = time.altzone
@@ -408,8 +408,8 @@ class BandwidthStats(graphPanel.GraphStats):
         queried["resetTime"] = "%i:%02i:%02i:%02i" % (days, hours, minutes, sec)
     
     # number of bytes used and in total for the accounting period
-    used = conn.getInfo("accounting/bytes")
-    left = conn.getInfo("accounting/bytes-left")
+    used = conn.getInfo("accounting/bytes", None)
+    left = conn.getInfo("accounting/bytes-left", None)
     
     if used and left:
       usedComp, leftComp = used.split(" "), left.split(" ")
diff --git a/src/cli/logPanel.py b/src/cli/logPanel.py
index b015ef1..ee7dee1 100644
--- a/src/cli/logPanel.py
+++ b/src/cli/logPanel.py
@@ -160,7 +160,7 @@ def getMissingEventTypes():
   if the GETINFO query fails.
   """
   
-  torEventTypes = torTools.getConn().getInfo("events/names")
+  torEventTypes = torTools.getConn().getInfo("events/names", None)
   
   if torEventTypes:
     torEventTypes = torEventTypes.split(" ")
diff --git a/src/starter.py b/src/starter.py
index 7c51aae..1672059 100644
--- a/src/starter.py
+++ b/src/starter.py
@@ -346,7 +346,7 @@ def _dumpConfig():
   else: armConfigEntry = "Arm Configuration: None"
   
   # dumps tor's version and configuration
-  torConfigEntry = "Tor (%s) Configuration:\n" % conn.getInfo("version")
+  torConfigEntry = "Tor (%s) Configuration:\n" % conn.getInfo("version", None)
   
   for line in conn.getInfo("config-text", "").split("\n"):
     if not line: continue
diff --git a/src/util/torConfig.py b/src/util/torConfig.py
index 851ef77..783fa84 100644
--- a/src/util/torConfig.py
+++ b/src/util/torConfig.py
@@ -182,7 +182,7 @@ def loadOptionDescriptions(loadPath = None, checkVersion = True):
       # 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")
+      configOptionQuery = conn.getInfo("config/names", None)
       if configOptionQuery:
         for line in configOptionQuery.strip().split("\n"):
           validOptions.append(line[:line.find(" ")].lower())
@@ -341,7 +341,7 @@ def getConfigLocation():
   """
   
   conn = torTools.getConn()
-  configLocation = conn.getInfo("config-file")
+  configLocation = conn.getInfo("config-file", None)
   torPid, torPrefix = conn.getMyPid(), conn.getPathPrefix()
   if not configLocation: raise IOError("unable to query the torrc location")
   
@@ -362,7 +362,7 @@ def getMultilineParameters():
   if MULTILINE_PARAM == None:
     conn, multilineEntries = torTools.getConn(), []
     
-    configOptionQuery = conn.getInfo("config/names")
+    configOptionQuery = conn.getInfo("config/names", None)
     if configOptionQuery:
       for line in configOptionQuery.strip().split("\n"):
         confOption, confType = line.strip().split(" ", 1)
@@ -445,7 +445,7 @@ def saveConf(destination = None, contents = None):
     # double check that "GETINFO config-text" is unavailable rather than just
     # giving an empty result
     
-    if torTools.getConn().getInfo("config-text") == None:
+    if torTools.getConn().getInfo("config-text", None) == None:
       raise IOError("determining the torrc requires Tor version 0.2.2.7")
   
   currentLocation = None
diff --git a/src/util/torInterpretor.py b/src/util/torInterpretor.py
index 4fa0dff..d88c137 100644
--- a/src/util/torInterpretor.py
+++ b/src/util/torInterpretor.py
@@ -296,7 +296,7 @@ class TorControlCompleter:
     conn = torTools.getConn()
     
     # adds all of the valid GETINFO options
-    infoOptions = conn.getInfo("info/names")
+    infoOptions = conn.getInfo("info/names", None)
     if infoOptions:
       for line in infoOptions.split("\n"):
         if " " in line:
@@ -315,7 +315,7 @@ class TorControlCompleter:
     else: self.commands.append("GETINFO ")
     
     # adds all of the valid GETCONF / SETCONF / RESETCONF options
-    confOptions = conn.getInfo("config/names")
+    confOptions = conn.getInfo("config/names", None)
     if confOptions:
       # individual options are '<name> <type>' pairs
       confEntries = [opt.split(" ", 1)[0] for opt in confOptions.split("\n")]
@@ -328,13 +328,13 @@ class TorControlCompleter:
       self.commands.append("RESETCONF ")
     
     # adds all of the valid SETEVENTS options
-    eventOptions = conn.getInfo("events/names")
+    eventOptions = conn.getInfo("events/names", None)
     if eventOptions:
       self.commands += ["SETEVENTS %s" % event for event in eventOptions.split(" ")]
     else: self.commands.append("SETEVENTS ")
     
     # adds all of the valid USEFEATURE options
-    featureOptions = conn.getInfo("features/names")
+    featureOptions = conn.getInfo("features/names", None)
     if featureOptions:
       self.commands += ["USEFEATURE %s" % feature for feature in featureOptions.split(" ")]
     else: self.commands.append("USEFEATURE ")
@@ -507,7 +507,7 @@ class ControlInterpretor:
         
         if arg == "GETINFO":
           # if this is the GETINFO option then also list the valid options
-          infoOptions = torTools.getConn().getInfo("info/names")
+          infoOptions = torTools.getConn().getInfo("info/names", None)
           
           if infoOptions:
             for line in infoOptions.split("\n"):
@@ -524,7 +524,7 @@ class ControlInterpretor:
         elif arg == "GETCONF":
           # lists all of the configuration options
           
-          confOptions = torTools.getConn().getInfo("config/names")
+          confOptions = torTools.getConn().getInfo("config/names", None)
           if confOptions:
             confEntries = [opt.split(" ", 1)[0] for opt in confOptions.split("\n")]
             
@@ -546,7 +546,7 @@ class ControlInterpretor:
             outputEntry.append((" - %s\n" % description, OUTPUT_FORMAT))
         elif arg == "SETEVENTS":
           # lists all of the event types
-          eventOptions = torTools.getConn().getInfo("events/names")
+          eventOptions = torTools.getConn().getInfo("events/names", None)
           if eventOptions:
             eventEntries = eventOptions.split()
             
@@ -561,7 +561,7 @@ class ControlInterpretor:
               outputEntry.append((lineContent + "\n", OUTPUT_FORMAT))
         elif arg == "USEFEATURE":
           # lists the feature options
-          featureOptions = torTools.getConn().getInfo("features/names")
+          featureOptions = torTools.getConn().getInfo("features/names", None)
           if featureOptions:
             outputEntry.append((featureOptions + "\n", OUTPUT_FORMAT))
         elif arg in ("LOADCONF", "POSTDESCRIPTOR"):
@@ -684,7 +684,7 @@ class ControlInterpretor:
     # if unsuccessful
     if not arg:
       # uses our fingerprint if we're a relay, otherwise gives an error
-      fingerprint = conn.getInfo("fingerprint")
+      fingerprint = conn.getInfo("fingerprint", None)
       
       if not fingerprint:
         outputEntry.append(("We aren't a relay, no information to provide", ERROR_FORMAT))
@@ -868,7 +868,7 @@ class ControlInterpretor:
       if cmd == "GETINFO":
         try:
           for param in arg.split():
-            response = conn.getInfo(param, suppressExc = False)
+            response = conn.getInfo(param)
             outputEntry.append((response + "\n", OUTPUT_FORMAT))
         except Exception, exc:
           outputEntry.append((str(exc), ERROR_FORMAT))
diff --git a/src/util/torTools.py b/src/util/torTools.py
index 7d742e4..742ea94 100644
--- a/src/util/torTools.py
+++ b/src/util/torTools.py
@@ -66,6 +66,8 @@ CACHE_GETINFO_PREFIX_ARGS = ("ip-to-country/", )
 # so erring on the side of inclusiveness by using the notice event instead.
 ADDR_CHANGED_MSG_PREFIX = ("Our IP Address has changed from", "Guessed our IP address as")
 
+UNDEFINED = "<Undefined_ >"
+
 UNKNOWN = "UNKNOWN" # value used by cached information if undefined
 CONFIG = {"torrc.map": {},
           "features.pathPrefix": "",
@@ -750,7 +752,7 @@ class Controller(TorCtl.PostEventListener):
     
     return result
   
-  def getInfo(self, param, default = None, suppressExc = True):
+  def getInfo(self, param, default = UNDEFINED):
     """
     Queries the control port for the given GETINFO option, providing the
     default if the response is undefined or fails for any reason (error
@@ -758,64 +760,20 @@ class Controller(TorCtl.PostEventListener):
     
     Arguments:
       param       - GETINFO option to be queried
-      default     - result if the query fails and exception's suppressed
-      suppressExc - suppresses lookup errors (returning the default) if true,
-                    otherwise this raises the original exception
+      default     - result if the query fails
     """
     
     self.connLock.acquire()
     
-    isGeoipRequest = param.startswith("ip-to-country/")
-    
-    # checks if this is an arg caching covers
-    isCacheArg = param in CACHE_ARGS
-    
-    if not isCacheArg:
-      for prefix in CACHE_GETINFO_PREFIX_ARGS:
-        if param.startswith(prefix):
-          isCacheArg = True
-          break
-    
-    startTime = time.time()
-    result, raisedExc, isFromCache = default, None, False
-    if self.isAlive():
-      cachedValue = self._cachedParam.get(param)
-      
-      if isCacheArg and cachedValue:
-        result = cachedValue
-        isFromCache = True
-      elif isGeoipRequest and self.isGeoipUnavailable():
-        # the geoip database aleady looks to be unavailable - abort the request
-        raisedExc = TorCtl.ErrorReply("Tor geoip database is unavailable.")
+    try:
+      if default != UNDEFINED:
+        return self.controller.get_info(param, default)
       else:
-        try:
-          getInfoVal = self.conn.get_info(param)[param]
-          if getInfoVal != None: result = getInfoVal
-          if isGeoipRequest: self.geoipFailureCount = -1
-        except (socket.error, TorCtl.ErrorReply, TorCtl.TorCtlClosed), exc:
-          if type(exc) == TorCtl.TorCtlClosed: self.close()
-          raisedExc = exc
-          
-          if isGeoipRequest and not self.geoipFailureCount == -1:
-            self.geoipFailureCount += 1
-            
-            if self.geoipFailureCount == GEOIP_FAILURE_THRESHOLD:
-              log.log(CONFIG["log.geoipUnavailable"], "Tor geoip database is unavailable.")
-    
-    if isCacheArg and result and not isFromCache:
-      self._cachedParam[param] = result
-    
-    if isFromCache:
-      msg = "GETINFO %s (cache fetch)" % param
-      log.log(CONFIG["log.torGetInfoCache"], msg)
-    else:
-      msg = "GETINFO %s (runtime: %0.4f)" % (param, time.time() - startTime)
-      log.log(CONFIG["log.torGetInfo"], msg)
-    
-    self.connLock.release()
-    
-    if not suppressExc and raisedExc: raise raisedExc
-    else: return result
+        return self.controller.get_info(param)
+    except stem.SocketClosed:
+      self.close()
+    finally:
+      self.connLock.release()
   
   def getOption(self, param, default = None, multiple = False, suppressExc = True):
     """
@@ -1336,7 +1294,7 @@ class Controller(TorCtl.PostEventListener):
           policyEntries += [policy.strip() for policy in exitPolicy.split(",")]
         
         # appends the default exit policy
-        defaultExitPolicy = self.getInfo("exit-policy/default")
+        defaultExitPolicy = self.getInfo("exit-policy/default", None)
         
         if defaultExitPolicy:
           policyEntries += defaultExitPolicy.split(",")
@@ -1352,7 +1310,7 @@ class Controller(TorCtl.PostEventListener):
         isPrivateRejected = self.getOption("ExitPolicyRejectPrivate", True)
         
         if isPrivateRejected:
-          myAddress = self.getInfo("address")
+          myAddress = self.getInfo("address", None)
           if myAddress: result = ExitPolicy("reject %s" % myAddress, result)
           
           result = ExitPolicy("reject private", result)
@@ -1378,7 +1336,7 @@ class Controller(TorCtl.PostEventListener):
     result = None
     if self.isAlive():
       if not relayFingerprint in self._consensusLookupCache:
-        nsEntry = self.getInfo("ns/id/%s" % relayFingerprint)
+        nsEntry = self.getInfo("ns/id/%s" % relayFingerprint, None)
         self._consensusLookupCache[relayFingerprint] = nsEntry
       
       result = self._consensusLookupCache[relayFingerprint]
@@ -1402,7 +1360,7 @@ class Controller(TorCtl.PostEventListener):
     result = None
     if self.isAlive():
       if not relayFingerprint in self._descriptorLookupCache:
-        descEntry = self.getInfo("desc/id/%s" % relayFingerprint)
+        descEntry = self.getInfo("desc/id/%s" % relayFingerprint, None)
         self._descriptorLookupCache[relayFingerprint] = descEntry
       
       result = self._descriptorLookupCache[relayFingerprint]
@@ -1466,7 +1424,7 @@ class Controller(TorCtl.PostEventListener):
     if self.isAlive():
       # query the nickname if it isn't yet cached
       if not relayFingerprint in self._nicknameLookupCache:
-        if relayFingerprint == self.getInfo("fingerprint"):
+        if relayFingerprint == self.getInfo("fingerprint", None):
           # this is us, simply check the config
           myNickname = self.getOption("Nickname", "Unnamed")
           self._nicknameLookupCache[relayFingerprint] = myNickname
@@ -1572,9 +1530,9 @@ class Controller(TorCtl.PostEventListener):
     if self.isAlive():
       # query the address if it isn't yet cached
       if not relayFingerprint in self._addressLookupCache:
-        if relayFingerprint == self.getInfo("fingerprint"):
+        if relayFingerprint == self.getInfo("fingerprint", None):
           # this is us, simply check the config
-          myAddress = self.getInfo("address")
+          myAddress = self.getInfo("address", None)
           myOrPort = self.getOption("ORPort")
           
           if myAddress and myOrPort:
@@ -1649,7 +1607,7 @@ class Controller(TorCtl.PostEventListener):
         #   "34f7e3b7c563afe76b71b6c52d038d37729aa4da"
         
         relayFingerprint = None
-        consensusEntry = self.getInfo("ns/name/%s" % relayNickname)
+        consensusEntry = self.getInfo("ns/name/%s" % relayNickname, None)
         if consensusEntry:
           encodedFp = consensusEntry.split()[2]
           decodedFp = (encodedFp + "=").decode('base64').encode('hex')
@@ -1757,7 +1715,7 @@ class Controller(TorCtl.PostEventListener):
       
       # initial check for event availability, using the 'events/names' GETINFO
       # option to detect invalid events
-      validEvents = self.getInfo("events/names")
+      validEvents = self.getInfo("events/names", None)
       
       if validEvents:
         validEvents = set(validEvents.split())
@@ -1940,7 +1898,7 @@ class Controller(TorCtl.PostEventListener):
     self._updateHeartbeat()
     self._consensusLookupCache = {}
     
-    myFingerprint = self.getInfo("fingerprint")
+    myFingerprint = self.getInfo("fingerprint", None)
     if myFingerprint:
       for ns in event.nslist:
         if ns.idhex == myFingerprint:
@@ -1980,7 +1938,7 @@ class Controller(TorCtl.PostEventListener):
     
     self.connLock.acquire()
     
-    myFingerprint = self.getInfo("fingerprint")
+    myFingerprint = self.getInfo("fingerprint", None)
     if not myFingerprint or myFingerprint in event.idlist:
       self._cachedParam["descEntry"] = None
       self._cachedParam["bwObserved"] = None
@@ -2118,9 +2076,9 @@ class Controller(TorCtl.PostEventListener):
     if isinstance(relayPort, str): relayPort = int(relayPort)
     
     # checks if this matches us
-    if relayAddress == self.getInfo("address"):
+    if relayAddress == self.getInfo("address", None):
       if not relayPort or relayPort == self.getOption("ORPort"):
-        return self.getInfo("fingerprint")
+        return self.getInfo("fingerprint", None)
     
     # if we haven't yet populated the ip -> fingerprint mappings then do so
     if self._fingerprintMappings == None:
@@ -2154,7 +2112,7 @@ class Controller(TorCtl.PostEventListener):
       
       # orconn-status has entries of the form:
       # $33173252B70A50FE3928C7453077936D71E45C52=shiven CONNECTED
-      orconnResults = self.getInfo("orconn-status")
+      orconnResults = self.getInfo("orconn-status", None)
       if orconnResults:
         for line in orconnResults.split("\n"):
           self._fingerprintsAttachedCache.append(line[1:line.find("=")])
@@ -2189,7 +2147,7 @@ class Controller(TorCtl.PostEventListener):
         if not nsCall: raise TorCtl.ErrorReply() # network consensus couldn't be fetched
         nsEntry = nsCall[0]
         
-        descEntry = self.getInfo("desc/id/%s" % entryFingerprint)
+        descEntry = self.getInfo("desc/id/%s" % entryFingerprint, None)
         if not descEntry: raise TorCtl.ErrorReply() # relay descriptor couldn't be fetched
         descLines = descEntry.split("\n")
         
@@ -2233,11 +2191,11 @@ class Controller(TorCtl.PostEventListener):
     if currentVal == None and (self.isAlive() or key == "pathPrefix"):
       # still unset - fetch value
       if key in ("nsEntry", "descEntry"):
-        myFingerprint = self.getInfo("fingerprint")
+        myFingerprint = self.getInfo("fingerprint", None)
         
         if myFingerprint:
           queryType = "ns" if key == "nsEntry" else "desc"
-          queryResult = self.getInfo("%s/id/%s" % (queryType, myFingerprint))
+          queryResult = self.getInfo("%s/id/%s" % (queryType, myFingerprint), None)
           if queryResult: result = queryResult.split("\n")
       elif key == "bwRate":
         # effective relayed bandwidth is the minimum of BandwidthRate,
@@ -2286,13 +2244,13 @@ class Controller(TorCtl.PostEventListener):
             result = line[2:].split()
             break
       elif key == "pid":
-        result = self.getInfo("process/pid")
+        result = self.getInfo("process/pid", None)
         
         if not result:
           result = getPid(int(self.getOption("ControlPort", 9051)), self.getOption("PidFile"))
       elif key == "user":
         # provides the empty string if the query fails
-        queriedUser = self.getInfo("process/user")
+        queriedUser = self.getInfo("process/user", None)
         
         if queriedUser != None and queriedUser != "":
           result = queriedUser
@@ -2315,7 +2273,7 @@ class Controller(TorCtl.PostEventListener):
               if psResults and len(psResults) >= 2: result = psResults[1].strip()
       elif key == "fdLimit":
         # provides -1 if the query fails
-        queriedLimit = self.getInfo("process/descriptor-limit")
+        queriedLimit = self.getInfo("process/descriptor-limit", None)
         
         if queriedLimit != None and queriedLimit != "-1":
           result = (int(queriedLimit), False)
@@ -2419,7 +2377,7 @@ class Controller(TorCtl.PostEventListener):
         # just "$<fingerprint>" OR <nickname>. The dolar sign can't be used in
         # nicknames so this can be used to differentiate.
         
-        circStatusResults = self.getInfo("circuit-status")
+        circStatusResults = self.getInfo("circuit-status", None)
         
         if circStatusResults == "":
           result = [] # we don't have any circuits



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits