jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/348211 )
Change subject: site_detect.py: Detect database error from reponse.content
......................................................................
site_detect.py: Detect database error from reponse.content
Raise ServerError upon detection.
Bug: T162991
Change-Id: Idd2d19a12e4b61c61aada01d17178d2c378561e9
---
M pywikibot/site_detect.py
1 file changed, 6 insertions(+), 0 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/site_detect.py b/pywikibot/site_detect.py
index 4eb78d7..d77a953 100644
--- a/pywikibot/site_detect.py
+++ b/pywikibot/site_detect.py
@@ -30,6 +30,10 @@
from urlparse import urljoin, urlparse
+SERVER_DB_ERROR_MSG = \
+ '<h1>Sorry! This site is experiencing technical
difficulties.</h1>'
+
+
class MWSite(object):
"""Minimal wiki site class."""
@@ -56,6 +60,8 @@
raise ServerError('Service Unavailable')
elif r.status == 500:
raise ServerError('Internal Server Error')
+ elif r.status == 200 and SERVER_DB_ERROR_MSG in r.content:
+ raise ServerError('Server cannot access the database')
if fromurl != r.data.url:
pywikibot.log('{0} redirected to {1}'.format(fromurl, r.data.url))
--
To view, visit
https://gerrit.wikimedia.org/r/348211
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idd2d19a12e4b61c61aada01d17178d2c378561e9
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>