From 6650d98af9ae26964884b006fafe796dfdf4cda8 Mon Sep 17 00:00:00 2001 From: emijrp Date: Mon, 5 Mar 2012 12:57:38 +0000 Subject: [PATCH] api/index.php checker git-svn-id: https://wikiteam.googlecode.com/svn/trunk@400 31edc4fc-5e31-b4c4-d58b-c8bc928bcb95 --- gui.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/gui.py b/gui.py index 63e57db..5c1156a 100644 --- a/gui.py +++ b/gui.py @@ -91,11 +91,12 @@ class App: self.label11.grid(row=0, column=0) self.entry11 = Entry(self.frame1, width=40) self.entry11.grid(row=0, column=1) + self.entry11.bind('', (lambda event: self.checkURL())) self.optionmenu11var = StringVar(self.frame1) self.optionmenu11var.set("api.php") self.optionmenu11 = OptionMenu(self.frame1, self.optionmenu11var, self.optionmenu11var.get(), "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 = Button(self.frame1, text="Check", command=lambda: thread.start_new_thread(self.checkURL, ()), width=5) self.button11.grid(row=0, column=3) #downloader tab (2) @@ -200,6 +201,27 @@ class App: helpmenu.add_command(label="WikiTeam homepage", command=lambda: webbrowser.open_new_tab(HOMEPAGE)) #end menu + def checkURL(self): + if re.search(ur"(?im)^https?://[^/]+\.[^/]+/", self.entry11.get()): #well-constructed URL?, one dot at least, aaaaa.com, but bb.aaaaa.com is allowed too + if self.optionmenu11var.get() == 'api.php': + self.msg('Please wait... Checking api.php...') + if dumpgenerator.checkAPI(self.entry11.get()): + self.entry11.config(background='lightgreen') + self.msg('api.php is OK!') + else: + self.entry11.config(background='red') + self.msg('api.php is incorrect!') + elif self.optionmenu11var.get() == 'index.php': + self.msg('Please wait... Checking index.php...') + if dumpgenerator.checkIndexphp(self.entry11.get()): + self.entry11.config(background='lightgreen') + self.msg('index.php is OK!') + else: + self.entry11.config(background='red') + self.msg('index.php is incorrect!') + else: + tkMessageBox.showerror("Error", "You have to write a correct api.php or index.php URL.") + def sumSizes(self, sizes): total = 0 for size in sizes: