deskbar-applet r2118 - in trunk: . deskbar/handlers



Author: sebp
Date: Mon Apr 14 19:55:41 2008
New Revision: 2118
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2118&view=rev

Log:
Fixed another unbound variable exception

Modified:
   trunk/ChangeLog
   trunk/deskbar/handlers/googlecodesearch.py
   trunk/deskbar/handlers/yahoo.py

Modified: trunk/deskbar/handlers/googlecodesearch.py
==============================================================================
--- trunk/deskbar/handlers/googlecodesearch.py	(original)
+++ trunk/deskbar/handlers/googlecodesearch.py	Mon Apr 14 19:55:41 2008
@@ -52,7 +52,6 @@
                  'max-results': MAX_RESULTS})
         
         matches = []
-        stream = None
         try:
             try:
                 stream = urllib.urlopen(url, proxies=get_proxy())
@@ -60,11 +59,16 @@
                 xml.sax.parse(stream, handler)
             except IOError, msg:
                 LOGGER.error("Could not open URL %s: %s, %s", url, msg[0], msg[1])
+                stream = None
             except xml.sax.SAXParseException, e:
                 LOGGER.exception(e)
+                handler = None
         finally:
             if stream != None:
                 stream.close()
+                
+        if handler == None:
+            return
             
         results = handler.get_results()
         for result in results:

Modified: trunk/deskbar/handlers/yahoo.py
==============================================================================
--- trunk/deskbar/handlers/yahoo.py	(original)
+++ trunk/deskbar/handlers/yahoo.py	Mon Apr 14 19:55:41 2008
@@ -100,7 +100,6 @@
         LOGGER.debug("Retrieving %s", url)
         
         matches = []
-        stream = 0
         try:
             try:
                 stream = urllib.urlopen(url, proxies=get_proxy())
@@ -108,12 +107,17 @@
                 xml.sax.parse(stream, handler)
             except IOError, msg:
                 LOGGER.error("Could not open URL %s: %s, %s", url, msg[0], msg[1])
+                stream = None
             except xml.sax.SAXParseException, e:
                 LOGGER.exception(e)
+                handler = None
         finally:
             if stream != None:
                 stream.close()
         
+        if handler == None:
+            return
+        
         LOGGER.debug('Got yahoo answer for: %s', qstring)
          
         num_results = len(handler.get_results())
@@ -259,7 +263,6 @@
         LOGGER.debug("Retrieving %s", url)
     
         matches = []
-        stream = None
         try:
             try:
                 stream = urllib.urlopen(url, proxies=get_proxy())
@@ -267,12 +270,17 @@
                 xml.sax.parse(stream, handler)
             except IOError, msg:
                 LOGGER.error("Could not open URL %s: %s, %s", url, msg[0], msg[1])
+                stream = None
             except xml.sax.SAXParseException, e:
                 LOGGER.exception(e)
+                handler = None
         finally:
             if stream != None:
                 stream.close()
             
+        if handler == None:
+            return
+            
         num_results = len(handler.get_suggestions())
         for i, suggestion in enumerate(handler.get_suggestions()):
             prio = self.get_priority() + num_results - i



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