2
0
mirror of https://github.com/WikiTeam/wikiteam synced 2024-11-10 13:10:27 +00:00

Follow API redirects

This commit is contained in:
PiRSquared17 2015-03-02 03:13:03 +00:00
parent dec0032971
commit 9c3c992319

View File

@ -1356,14 +1356,19 @@ def getParameters(params=[]):
def checkAPI(api=None, session=None): def checkAPI(api=None, session=None):
""" Checking API availability """ """ Checking API availability """
global cj global cj
r = session.post( # handle redirects
url=api, for i in range(4):
data={ print 'Checking API...', api
'action': 'query', r = session.post(
'meta': 'siteinfo', url=api,
'format': 'json'}) data={
resultText = r.text 'action': 'query',
print 'Checking API...', api 'meta': 'siteinfo',
'format': 'json'})
resultText = r.text
if r.url == api:
break
api = r.url
if "MediaWiki API is not enabled for this site." in resultText: if "MediaWiki API is not enabled for this site." in resultText:
return False return False
try: try: