jenkins-bot has submitted this change and it was merged.

Change subject: Catch pywikibot.exceptions.Error when looking for categories
......................................................................


Catch pywikibot.exceptions.Error when looking for categories

This is a bit heavy handed, but will allow the bot to keep going
when choking on an image instead of dying.

Bug: T111921
Change-Id: Idf4ddcefbfd6e72e805a39022e423a2434ca7872
---
M erfgoedbot/categorize_images.py
1 file changed, 6 insertions(+), 1 deletion(-)

Approvals:
  Jean-Frédéric: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/erfgoedbot/categorize_images.py b/erfgoedbot/categorize_images.py
index c6d4d13..467768c 100644
--- a/erfgoedbot/categorize_images.py
+++ b/erfgoedbot/categorize_images.py
@@ -294,6 +294,8 @@
                                      (monumentArticle.title(),))
             except pywikibot.exceptions.InvalidTitle:
                 pywikibot.output(u'Incorrect article title %s' % 
(monumentArticleTitle,))
+            except pywikibot.exceptions.Error as e:
+                pywikibot.output(u'Error occured with monument %s: %s' % 
(monumentId, str(e)))
     # Option three is to see if the list contains Commonscat links (whole list)
     if not newcats:
         monumentList = getList(lang, monumentSource)
@@ -302,7 +304,10 @@
             return False
         if monumentList.isRedirectPage():
             monumentList = monumentList.getRedirectTarget()
-        newcats = getCategories(monumentList, commonsCatTemplates)
+        try:
+            newcats = getCategories(monumentList, commonsCatTemplates)
+        except pywikibot.exceptions.Error as e:
+            pywikibot.output(u'Error occured with monument %s: %s' % 
(monumentId, str(e)))
     return newcats
 
 

-- 
To view, visit https://gerrit.wikimedia.org/r/237966
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idf4ddcefbfd6e72e805a39022e423a2434ca7872
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/heritage
Gerrit-Branch: master
Gerrit-Owner: Jean-Frédéric <[email protected]>
Gerrit-Reviewer: Jean-Frédéric <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to