converting api check and indexphp check to fuctions

git-svn-id: https://wikiteam.googlecode.com/svn/trunk@395 31edc4fc-5e31-b4c4-d58b-c8bc928bcb95
pull/117/head
emijrp 12 years ago
parent b01e4bcd66
commit 4a5e1bc880

@ -780,11 +780,7 @@ def getParameters(params=[]):
if config['api']:
#check api.php
f = urllib.urlopen(config['api'])
raw = f.read()
f.close()
print 'Checking api.php...'
if re.search(r'action=query', raw):
if checkAPI(config['api']):
print 'api.php is OK'
else:
print 'Error in api.php, please, provide a correct path to api.php'
@ -792,16 +788,10 @@ def getParameters(params=[]):
if config['index']:
#check index.php
req = urllib2.Request(url=config['index'], data=urllib.urlencode({'title': 'Special:Version', }), headers={'User-Agent': getUserAgent()})
f = urllib2.urlopen(req)
raw = f.read()
f.close()
print 'Checking index.php...'
if re.search(r'(This wiki is powered by|<h2 id="mw-version-license">)', raw):
if checkIndexphp(config['index']):
print 'index.php is OK'
else:
print 'Error in index.php, please, provide a correct path to index.php'
print raw[:500]
sys.exit()
#calculating path, if not defined by user with --path=
@ -810,6 +800,25 @@ def getParameters(params=[]):
return config, other
def checkAPI(api):
f = urllib.urlopen(api)
raw = f.read()
f.close()
print 'Checking api.php...'
if re.search(r'action=query', raw):
return True
return False
def checkIndexphp(indexphp):
req = urllib2.Request(url=indexphp, data=urllib.urlencode({'title': 'Special:Version', }), headers={'User-Agent': getUserAgent()})
f = urllib2.urlopen(req)
raw = f.read()
f.close()
print 'Checking index.php...'
if re.search(r'(This wiki is powered by|<h2 id="mw-version-license">)', raw):
return True
return False
def removeIP(raw=''):
""" Remove IP from HTML comments <!-- --> """
raw = re.sub(r'\d+\.\d+\.\d+\.\d+', '0.0.0.0', raw)

@ -85,10 +85,14 @@ class App:
#dump generator tab (1)
self.label11 = Label(self.frame1, text="Wiki URL:")
self.label11.grid(row=0, column=0)
self.entry11 = Entry(self.frame1, width=20)
self.entry11 = Entry(self.frame1, width=40)
self.entry11.grid(row=0, column=1)
self.optionmenu11var = StringVar(self.frame1)
self.optionmenu11var.set("api")
self.optionmenu11 = OptionMenu(self.frame1, self.optionmenu11var, "api", "index.php")
self.optionmenu11.grid(row=0, column=2)
self.button11 = Button(self.frame1, text="Check", command=lambda: thread.start_new_thread(self.callback, ()), width=5)
self.button11.grid(row=0, column=2)
self.button11.grid(row=0, column=3)
#downloader tab (2)
self.label25var = StringVar(self.frame2)

Loading…
Cancel
Save