[or-cvs] r22624: {arm} fix: crashing issue and minor display issue if orport is uns (in arm/trunk: interface util)

Damian Johnson atagar1 at gmail.com
Fri Jul 9 16:40:31 UTC 2010


Author: atagar
Date: 2010-07-09 16:40:31 +0000 (Fri, 09 Jul 2010)
New Revision: 22624

Modified:
   arm/trunk/interface/headerPanel.py
   arm/trunk/util/torTools.py
Log:
fix: crashing issue and minor display issue if orport is unset



Modified: arm/trunk/interface/headerPanel.py
===================================================================
--- arm/trunk/interface/headerPanel.py	2010-07-09 16:16:31 UTC (rev 22623)
+++ arm/trunk/interface/headerPanel.py	2010-07-09 16:40:31 UTC (rev 22624)
@@ -118,6 +118,9 @@
       if len(entry) + len(label) <= leftWidth: entry += label
       else: break
     
+    # strips off divider if nicknames undefined (happens if orport is unset)
+    if entry.startswith(" - "): entry = entry[3:]
+    
     if self.vals["tor/isAuthPassword"]: authType = "password"
     elif self.vals["tor/isAuthCookie"]: authType = "cookie"
     else: authType = "open"

Modified: arm/trunk/util/torTools.py
===================================================================
--- arm/trunk/util/torTools.py	2010-07-09 16:16:31 UTC (rev 22623)
+++ arm/trunk/util/torTools.py	2010-07-09 16:40:31 UTC (rev 22624)
@@ -356,8 +356,8 @@
   def getInfo(self, param, default = None, suppressExc = True):
     """
     Queries the control port for the given GETINFO option, providing the
-    default if the response fails for any reason (error response, control port
-    closed, initiated, etc).
+    default if the response is undefined or fails for any reason (error
+    response, control port closed, initiated, etc).
     
     Arguments:
       param       - GETINFO option to be queried
@@ -372,7 +372,8 @@
     result, raisedExc = default, None
     if self.isAlive():
       try:
-        result = self.conn.get_info(param)[param]
+        getInfoVal = self.conn.get_info(param)[param]
+        if getInfoVal != None: result = getInfoVal
       except (socket.error, TorCtl.ErrorReply, TorCtl.TorCtlClosed), exc:
         if type(exc) == TorCtl.TorCtlClosed: self.close()
         raisedExc = exc
@@ -388,8 +389,9 @@
   def getOption(self, param, default = None, multiple = False, suppressExc = True):
     """
     Queries the control port for the given configuration option, providing the
-    default if the response fails for any reason. If multiple values exist then
-    this arbitrarily returns the first unless the multiple flag is set.
+    default if the response is undefined or fails for any reason. If multiple
+    values exist then this arbitrarily returns the first unless the multiple
+    flag is set.
     
     Arguments:
       param       - configuration option to be queried
@@ -409,7 +411,9 @@
         if multiple:
           for key, value in self.conn.get_option(param):
             if value != None: result.append(value)
-        else: result = self.conn.get_option(param)[0][1]
+        else:
+          getConfVal = self.conn.get_option(param)[0][1]
+          if getConfVal != None: result = getConfVal
       except (socket.error, TorCtl.ErrorReply, TorCtl.TorCtlClosed), exc:
         if type(exc) == TorCtl.TorCtlClosed: self.close()
         result, raisedExc = default, exc
@@ -420,6 +424,7 @@
     self.connLock.release()
     
     if not suppressExc and raisedExc: raise raisedExc
+    elif result == []: return default
     else: return result
   
   def getMyNetworkStatus(self, default = None):



More information about the tor-commits mailing list