Revision: 4489
Author: btongminh
Date: 2007-10-31 20:58:43 +0000 (Wed, 31 Oct 2007)
Log Message:
-----------
Add a new config setting for solving captchas (default: backwards-compatible)
Modified Paths:
--------------
trunk/pywikipedia/config.py
trunk/pywikipedia/login.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/config.py
===================================================================
--- trunk/pywikipedia/config.py 2007-10-31 20:37:03 UTC (rev 4488)
+++ trunk/pywikipedia/config.py 2007-10-31 20:58:43 UTC (rev 4489)
@@ -45,6 +45,10 @@
disambiguation_comment = {}
gdab_namespaces = {}
+# Solve captchas in the webbrowser. Setting this to False will result in the
+# exception CaptchaError be thrown if a captcha is encountered.
+solve_captcha = True
+
# Some sites will require password identication to access the HTML pages at
# the site. If you have any such site, add lines to your user-config.py of
# the following form:
Modified: trunk/pywikipedia/login.py
===================================================================
--- trunk/pywikipedia/login.py 2007-10-31 20:37:03 UTC (rev 4488)
+++ trunk/pywikipedia/login.py 2007-10-31 20:58:43 UTC (rev 4489)
@@ -156,6 +156,8 @@
captchaR = re.compile('<input type="hidden" name="wpCaptchaId" id="wpCaptchaId" value="(?P<id>\d+)" />')
match = captchaR.search(data)
if match:
+ if not config.solve_captcha:
+ raise wikipedia.CaptchaError(id)
id = match.group('id')
url = self.site.protocol() + '://' + self.site.hostname() + self.site.captcha_image_address(id)
answer = wikipedia.ui.askForCaptcha(url)
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2007-10-31 20:37:03 UTC (rev 4488)
+++ trunk/pywikipedia/wikipedia.py 2007-10-31 20:58:43 UTC (rev 4489)
@@ -203,6 +203,9 @@
class PageNotFound(Error):
"""Page not found in list"""
+class CaptchaError(Error):
+ """Captcha is asked and config.solve_captcha == False."""
+
SaxError = xml.sax._exceptions.SAXParseException
# Pre-compile re expressions
Revision: 4484
Author: valhallasw
Date: 2007-10-30 16:42:25 +0000 (Tue, 30 Oct 2007)
Log Message:
-----------
try: except: finally: -> try: (try: except:) finally: ,for python 2.4 compatibility. By Filnik
Modified Paths:
--------------
trunk/pywikipedia/welcome.py
Modified: trunk/pywikipedia/welcome.py
===================================================================
--- trunk/pywikipedia/welcome.py 2007-10-29 06:41:05 UTC (rev 4483)
+++ trunk/pywikipedia/welcome.py 2007-10-30 16:42:25 UTC (rev 4484)
@@ -861,24 +861,25 @@
if __name__ == "__main__":
# Use try and finally, to put the wikipedia.stopme() always at the end of the code.
try:
- number_user = None
- settingsBot = mainSettings()
- # Take two settings for the "finally" block.
- filename = settingsBot[2]
- random = settingsBot[11]
- savedata = settingsBot[13]
- # I need to know what is the number_user, in this way I get it.
- for x in main(settingsBot):
- try:
- number_user = x[0]
- except TypeError:
- number_user = x
- else:
- break
- except wikipedia.BadTitle:
- wikipedia.output(u"Wikidown or server's problem. Quit.")
- wikipedia.stopme()
- # finally:
+ try:
+ number_user = None
+ settingsBot = mainSettings()
+ # Take two settings for the "finally" block.
+ filename = settingsBot[2]
+ random = settingsBot[11]
+ savedata = settingsBot[13]
+ # I need to know what is the number_user, in this way I get it.
+ for x in main(settingsBot):
+ try:
+ number_user = x[0]
+ except TypeError:
+ number_user = x
+ else:
+ break
+ except wikipedia.BadTitle:
+ wikipedia.output(u"Wikidown or server's problem. Quit.")
+ wikipedia.stopme()
+ finally:
# If there is the savedata, the script must save the number_user.
if random == True and savedata == True and number_user != None:
f = file(filename, 'w')
Patches item #1820745, was opened at 2007-10-26 11:52
Message generated for change (Comment added) made by leogregianin
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1820745&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Rotem Liss (rotemliss)
Assigned to: Nobody/Anonymous (nobody)
Summary: Updates for Hebrew translation
Initial Comment:
Attaching updates for the Hebrew translation, including copying the Hebrew policy of interwikis to the sister projects.
----------------------------------------------------------------------
>Comment By: Leonardo Gregianin (leogregianin)
Date: 2007-10-29 09:18
Message:
Logged In: YES
user_id=1136737
Originator: NO
Hi Rotem Liss, do you can apply this patch in pywikipedia repository with
the same password of mediawiki.
svn+ssh://your_name@svn.wikimedia.org/svnroot/pywikipedia
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1820745&group_…
Bugs item #1821360, was opened at 2007-10-27 22:50
Message generated for change (Comment added) made by rotemliss
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1821360&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: André Malafaya Baptista (malafaya)
Assigned to: Nobody/Anonymous (nobody)
Summary: cosmetic_changes.py crashes
Initial Comment:
Trace below should be self-explanatory:
>cosmetic_changes.py -lang:pt Portugal
Checked for running processes. 2 processes currently running, including the current process.
ATTENTION: You can run this script as a stand-alone for testing purposes.
However, the changes are that are made are only minor, and other users
might get angry if you fill the version histories and watchlists with such
irrelevant changes.
Do you really want to continue? ([y]es, [N]o) y
Getting 1 pages from wikipedia:pt...
>>> Portugal <<<
Traceback (most recent call last):
File "D:\Work\pywikipediabot-HEAD\pywikipedia\cosmetic_changes.py", line 398,
in <module>
main()
File "D:\Work\pywikipediabot-HEAD\pywikipedia\cosmetic_changes.py", line 394,
in main
bot.run()
File "D:\Work\pywikipediabot-HEAD\pywikipedia\cosmetic_changes.py", line 359,
in run
self.treat(page)
File "D:\Work\pywikipediabot-HEAD\pywikipedia\cosmetic_changes.py", line 340,
in treat
changedText = ccToolkit.change(page.get())
File "D:\Work\pywikipediabot-HEAD\pywikipedia\cosmetic_changes.py", line 88, i
n change
text = self.cleanUpLinks(text)
File "D:\Work\pywikipediabot-HEAD\pywikipedia\cosmetic_changes.py", line 259,
in cleanUpLinks
text = wikipedia.replaceExcept(text, linkR, handleOneLink, ['comment', 'math
', 'nowiki', 'pre', 'startspace'])
File "D:\Work\pywikipediabot-HEAD\pywikipedia\wikipedia.py", line 2813, in rep
laceExcept
new = new.replace('\\n', '\n')
AttributeError: 'function' object has no attribute 'replace'
----------------------------------------------------------------------
Comment By: Rotem Liss (rotemliss)
Date: 2007-10-29 13:44
Message:
Logged In: YES
user_id=1327030
Originator: NO
The problem in wikipedia.py, in the function replaceExcept. "new" may be
either function or string (or unicode string), but in line 2813, the
replace method is called (if the OS is Win32), without knowing if it is a
function or a string. The code block in lines 2806-2813 should be moved
down, after the "except TypeError" part, where it is known for sure that
"new" is a string.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1821360&group_…