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



Author: sebp
Date: Mon Apr 14 20:10:14 2008
New Revision: 2119
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2119&view=rev

Log:
Fixed yet another unbound variable exception.
Can I ever get this right?

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 20:10:14 2008
@@ -52,20 +52,22 @@
                  'max-results': MAX_RESULTS})
         
         matches = []
+        
+        try:
+            stream = urllib.urlopen(url, proxies=get_proxy())
+        except IOError, msg:
+            LOGGER.error("Could not open URL %s: %s, %s", url, msg[0], msg[1])
+            return
+        
         try:
             try:
-                stream = urllib.urlopen(url, proxies=get_proxy())
                 handler = GoogleCodeSearchFeedParser()
                 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()
+            stream.close()
                 
         if handler == None:
             return

Modified: trunk/deskbar/handlers/yahoo.py
==============================================================================
--- trunk/deskbar/handlers/yahoo.py	(original)
+++ trunk/deskbar/handlers/yahoo.py	Mon Apr 14 20:10:14 2008
@@ -100,21 +100,23 @@
         LOGGER.debug("Retrieving %s", url)
         
         matches = []
+        
+        try:
+            stream = urllib.urlopen(url, proxies=get_proxy())
+        except IOError, msg:
+            LOGGER.error("Could not open URL %s: %s, %s", url, msg[0], msg[1])
+            return
+    
         try:
             try:
-                stream = urllib.urlopen(url, proxies=get_proxy())
                 handler = WebSearchResultsParser()
                 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()
-        
+            stream.close()
+    
         if handler == None:
             return
         
@@ -263,20 +265,22 @@
         LOGGER.debug("Retrieving %s", url)
     
         matches = []
+        
+        try:
+            stream = urllib.urlopen(url, proxies=get_proxy())
+        except IOError, msg:
+            LOGGER.error("Could not open URL %s: %s, %s", url, msg[0], msg[1])
+            return
+        
         try:
             try:
-                stream = urllib.urlopen(url, proxies=get_proxy())
                 handler = RelatedSuggestionResultsParser()
                 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()
+            stream.close()
             
         if handler == None:
             return



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