Revision: 6012 Author: russblau Date: 2008-10-23 21:07:57 +0000 (Thu, 23 Oct 2008)
Log Message: ----------- Catch and log API warning messages.
Modified Paths: -------------- branches/rewrite/pywikibot/data/api.py
Modified: branches/rewrite/pywikibot/data/api.py =================================================================== --- branches/rewrite/pywikibot/data/api.py 2008-10-22 12:10:35 UTC (rev 6011) +++ branches/rewrite/pywikibot/data/api.py 2008-10-23 21:07:57 UTC (rev 6012) @@ -17,6 +17,7 @@ import traceback import time import urllib +import warnings
import config import pywikibot @@ -43,6 +44,11 @@ return "%(code)s: %(info)s" % self.__dict__
+class APIWarning(UserWarning): + """The API returned a warning message.""" + pass + + class TimeoutError(pywikibot.Error): pass
@@ -222,6 +228,12 @@ else: self.site._userinfo = result['query']['userinfo']
+ if "warnings" in result: + modules = [k for k in result["warning"] if k != "info"] + logger.warn( + "API warning (%s): %s" + % (", ".join(modules), result['warnings']['info'])) + warnings.warn(result['warnings']['info']) if "error" not in result: return result if "*" in result["error"]:
pywikipedia-l@lists.wikimedia.org