jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] Do not raise exception for api warnings
......................................................................
[bugfix] Do not raise exception for api warnings
API warnings in logpages method lead to a blocker and all related
scripts failed. Now warning will be printed using the same code
snippet as in core and the script is kept alive.
bugfix for bug 72749
Change-Id: Id48be5ef525d7b05d4cd58f24b839375e380c99e
---
M wikipedia.py
1 file changed, 21 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/wikipedia.py b/wikipedia.py
index b57f01c..248431b 100644
--- a/wikipedia.py
+++ b/wikipedia.py
@@ -7897,9 +7897,29 @@
output('%(info)s' % result.get('error'))
raise BadTitle
# FIXME: Throw proper exceptions instead of "Error"
- if 'error' in result or 'warnings' in result:
+ if 'error' in result:
output('%s' % result)
raise Error
+
+ # _handle_warnings from core
+ for mod, warning in result['warnings'].items():
+ if mod == 'info':
+ continue
+ if '*' in warning:
+ text = warning['*']
+ elif 'html' in warning:
+ # Bugzilla 49978
+ text = warning['html']['*']
+ else:
+ pywikibot.warning(
+ u'API warning ({0})of unknown format: {1}'.
+ format(mod, warning))
+ continue
+ # multiple warnings are in text separated by a newline
+ for single_warning in text.splitlines():
+ pywikibot.warning(u"API warning (%s): %s"
+ % (mod, single_warning))
+
for c in result['query']['logevents']:
if (not namespace or c['ns'] in namespace) and \
'actionhidden' not in c.keys():
--
To view, visit
https://gerrit.wikimedia.org/r/170075
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id48be5ef525d7b05d4cd58f24b839375e380c99e
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>