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

Try getting index.php from siteinfo API

Fixes #49
This commit is contained in:
Pi R. Squared 2014-09-14 11:59:17 -04:00
parent ac1a7defae
commit 498b64da3f

View File

@ -1093,7 +1093,11 @@ def getParameters(params=[]):
#print api #print api
#print index #print index
if api and checkAPI(api=api, session=session): index2 = None
check = api and checkAPI(api=api, session=session)
if check:
index2 = check[1]
print 'API is OK' print 'API is OK'
else: else:
print 'Error in API, please, provide a correct path to API' print 'Error in API, please, provide a correct path to API'
@ -1102,8 +1106,14 @@ def getParameters(params=[]):
if index and checkIndex(index=index, cookies=args.cookies, session=session): if index and checkIndex(index=index, cookies=args.cookies, session=session):
print 'index.php is OK' print 'index.php is OK'
else: else:
print 'Error in index.php, please, provide a correct path to index.php' index = index2
sys.exit(1) if index and index.startswith('//'):
index = args.wiki.split('//')[0] + index
if index and checkIndex(index=index, cookies=args.cookies, session=session):
print 'index.php is OK'
else:
print 'Error in index.php, please, provide a correct path to index.php'
sys.exit(1)
# check user and pass (one requires both) # check user and pass (one requires both)
if (args.user and not args.password) or (args.password and not args.user): if (args.user and not args.password) or (args.password and not args.user):
@ -1185,7 +1195,10 @@ def checkAPI(api=None, session=None):
try: try:
result = json.loads(resultText) result = json.loads(resultText)
if 'query' in result: if 'query' in result:
return True if 'general' in result['query'] and 'script' in result['query']['general'] and 'server' in result['query']['general']:
return (True, result['query']['general']['server']+result['query']['general']['script'])
else:
return (True, None)
except ValueError: except ValueError:
return False return False
return False return False