[Pywikipedia-l] SVN: [6088] trunk/pywikipedia/imagerecat.py

multichill at svn.wikimedia.org multichill at svn.wikimedia.org
Wed Nov 12 11:19:15 UTC 2008


Revision: 6088
Author:   multichill
Date:     2008-11-12 11:19:15 +0000 (Wed, 12 Nov 2008)

Log Message:
-----------
Catch IOError when filtering parents

Modified Paths:
--------------
    trunk/pywikipedia/imagerecat.py

Modified: trunk/pywikipedia/imagerecat.py
===================================================================
--- trunk/pywikipedia/imagerecat.py	2008-11-12 11:10:52 UTC (rev 6087)
+++ trunk/pywikipedia/imagerecat.py	2008-11-12 11:19:15 UTC (rev 6088)
@@ -234,11 +234,14 @@
         toFilter = toFilter + "[[Category:" + cat + "]]\n"
     #try:
     parameters = urllib.urlencode({'source' : toFilter.encode('utf-8'), 'bot' : '1'})
-    filterCategoriesPage = urllib.urlopen("http://toolserver.org/~multichill/filtercats.php?%s" % parameters)
-    #print filterCategoriesPage.read().decode('utf-8')
     filterCategoriesRe = re.compile('\[\[Category:([^\]]*)\]\]')
-    result = filterCategoriesRe.findall(filterCategoriesPage.read().decode('utf-8'))
-    #except:
+    try:
+        filterCategoriesPage = urllib.urlopen("http://toolserver.org/~multichill/filtercats.php?%s" % parameters)
+        result = filterCategoriesRe.findall(filterCategoriesPage.read().decode('utf-8'))
+    except IOError:
+        #Something is wrong, forget about this filter and just return the input
+        return categories
+        
     if not result:
         #Is empty, dont want to remove all categories
         return categories





More information about the Pywikipedia-l mailing list