Revision: 4331
Author: russblau
Date: 2007-09-19 12:35:52 +0000 (Wed, 19 Sep 2007)
Log Message:
-----------
bugfix (article instead of page); break long lines
Modified Paths:
--------------
trunk/pywikipedia/catlib.py
Modified: trunk/pywikipedia/catlib.py
===================================================================
--- trunk/pywikipedia/catlib.py 2007-09-19 09:02:24 UTC (rev 4330)
+++ trunk/pywikipedia/catlib.py 2007-09-19 12:35:52 UTC (rev 4331)
@@ -441,10 +441,11 @@
% article.title())
except wikipedia.PageNotSaved, error:
wikipedia.output(u"Saving page [[%s]] failed: %s"
- % (page.title(), error.message))
+ % (article.title(), error.message))
return
- # This loop will replace all occurrences of the category to be changed, and remove duplicates.
+ # This loop will replace all occurrences of the category to be changed,
+ # and remove duplicates.
newCatList = []
newCatSet = set()
for i in range(len(cats)):
@@ -455,7 +456,8 @@
sortKey = cat.sortKey
if newCat:
if newCat.title() not in newCatSet:
- newCategory = Category(site, newCat.title(), sortKey = sortKey)
+ newCategory = Category(site, newCat.title(),
+ sortKey=sortKey)
newCatSet.add(newCat.title())
newCatList.append(newCategory)
elif cat.title() not in newCatSet:
@@ -468,8 +470,11 @@
text = article.get(nofollow_redirects=True)
try:
text = wikipedia.replaceCategoryLinks(text, newCatList)
- except ValueError: #Make sure that the only way replaceCategoryLinks() can return a ValueError is in the case of interwiki links to self.
- wikipedia.output(u'Skipping %s because of interwiki link to self' % (article))
+ except ValueError:
+ # Make sure that the only way replaceCategoryLinks() can return
+ # a ValueError is in the case of interwiki links to self.
+ wikipedia.output(
+ u'Skipping %s because of interwiki link to self' % article)
try:
article.put(text, comment)
except wikipedia.EditConflict:
Revision: 4329
Author: wikipedian
Date: 2007-09-19 08:32:23 +0000 (Wed, 19 Sep 2007)
Log Message:
-----------
show captcha in web browser
Modified Paths:
--------------
trunk/pywikipedia/userinterfaces/terminal_interface.py
Modified: trunk/pywikipedia/userinterfaces/terminal_interface.py
===================================================================
--- trunk/pywikipedia/userinterfaces/terminal_interface.py 2007-09-19 08:19:07 UTC (rev 4328)
+++ trunk/pywikipedia/userinterfaces/terminal_interface.py 2007-09-19 08:32:23 UTC (rev 4329)
@@ -233,9 +233,10 @@
def askForCaptcha(self, url):
try:
- import gui
- # TODO
- raise ImportError
+ import webbrowser
+ wikipedia.output(u'Opening CAPTCHA in your web browser...')
+ webbrowser.open(url)
+ return wikipedia.input(u'What is the solution of the CAPTCHA that is shown in your web browser?')
except ImportError, e:
- return wikipedia.input('What is the solution of the CAPTCHA at %s ?' % url)
+ return wikipedia.input(u'What is the solution of the CAPTCHA at %s ?' % url)
Revision: 4328
Author: cosoleto
Date: 2007-09-19 08:19:07 +0000 (Wed, 19 Sep 2007)
Log Message:
-----------
Fix to not download the same file more times when upload_image() is recalled
Modified Paths:
--------------
trunk/pywikipedia/upload.py
Modified: trunk/pywikipedia/upload.py
===================================================================
--- trunk/pywikipedia/upload.py 2007-09-19 07:31:22 UTC (rev 4327)
+++ trunk/pywikipedia/upload.py 2007-09-19 08:19:07 UTC (rev 4328)
@@ -100,21 +100,22 @@
If the upload fails, the user is asked whether to try again or not.
If the user chooses not to retry, returns null.
"""
- # Get file contents
- if '://' in self.url:
- uo = wikipedia.MyURLopener()
- file = uo.open(self.url,"rb")
- else:
- # Opening local files with MyURLopener would be possible, but we
- # don't do it because it only accepts ASCII characters in the
- # filename.
- file = open(self.url,"rb")
- wikipedia.output(u'Reading file %s' % self.url)
- contents = file.read()
- if contents.find("The requested URL was not found on this server.") != -1:
- print "Couldn't download the image."
- return
- file.close()
+ if not hasattr(self, "_contents"):
+ # Get file contents
+ if '://' in self.url:
+ uo = wikipedia.MyURLopener()
+ file = uo.open(self.url)
+ else:
+ # Opening local files with MyURLopener would be possible, but we
+ # don't do it because it only accepts ASCII characters in the
+ # filename.
+ file = open(self.url,"rb")
+ wikipedia.output(u'Reading file %s' % self.url)
+ self._contents = file.read()
+ if self._contents.find("The requested URL was not found on this server.") != -1:
+ print "Couldn't download the image."
+ return
+ file.close()
# Isolate the pure name
filename = self.url
if '/' in filename:
@@ -197,7 +198,7 @@
response, returned_html = post_multipart(self.targetSite,
self.targetSite.upload_address(),
formdata.items(),
- (('wpUploadFile', encodedFilename, contents),),
+ (('wpUploadFile', encodedFilename, self._contents),),
cookies = self.targetSite.cookies()
)
# There are 2 ways MediaWiki can react on success: either it gives
@@ -233,6 +234,7 @@
answer = wikipedia.inputChoice(u"You have recevied an upload warning message. Ignore?", ['Yes', 'No'], ['y', 'N'], 'N')
if answer in ["y", "Y"]:
self.ignoreWarning = 1
+ self.keepFilename = True
return self.upload_image(debug)
else:
answer = wikipedia.inputChoice(u'Upload of %s probably failed. Above you see the HTML page which was returned by MediaWiki. Try again?' % filename, ['Yes', 'No'], ['y', 'N'], 'N')
Bugs item #1616771, was opened at 2006-12-15 23:58
Message generated for change (Comment added) made by cosoleto
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1616771&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: Daniel Herding (wikipedian)
Assigned to: Nobody/Anonymous (nobody)
Summary: upload.py: ignoreWarnings flag doesn't work
Initial Comment:
I have added a flag ignoreWarnings for UploadRobot, such that the bot won't just overwrite images.
Unfortunatelly it doesn't work yet (images are overwritten nonetheless), and I don't know why.
----------------------------------------------------------------------
Comment By: Francesco Cosoleto (cosoleto)
Date: 2007-09-19 00:32
Message:
Logged In: YES
user_id=181280
Originator: NO
Fixed in r4326.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2007-06-21 18:22
Message:
Logged In: NO
this bug is still applicable as of 21/06/07
----------------------------------------------------------------------
Comment By: siebrand (siebrand)
Date: 2007-04-26 21:30
Message:
Logged In: YES
user_id=1107255
Originator: NO
Please let us know if this bug report is still applicable to the current
code. If no response is given, the bug report will be closed one month from
now. This message was added in an effort to reduce the number of open
issues on this project. Siebrand
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1616771&group_…
Revision: 4326
Author: cosoleto
Date: 2007-09-18 22:24:47 +0000 (Tue, 18 Sep 2007)
Log Message:
-----------
bug #1616771 fixed "upload.py: ignoreWarnings flag doesn't work"
Modified Paths:
--------------
trunk/pywikipedia/upload.py
Modified: trunk/pywikipedia/upload.py
===================================================================
--- trunk/pywikipedia/upload.py 2007-09-18 22:21:56 UTC (rev 4325)
+++ trunk/pywikipedia/upload.py 2007-09-18 22:24:47 UTC (rev 4326)
@@ -73,7 +73,6 @@
ignoreWarning - Set this to True if you want to upload even if another
file would be overwritten or another mistake would be
risked.
- Attention: This parameter doesn't work yet for unknown reason.
"""
self.url = url
self.urlEncoding = urlEncoding
@@ -180,8 +179,6 @@
# This somehow doesn't work.
if self.ignoreWarning:
formdata["wpIgnoreWarning"] = "1"
- else:
- formdata["wpIgnoreWarning"] = "0"
# try to encode the strings to the encoding used by the target site.
# if that's not possible (e.g. because there are non-Latin-1 characters and
@@ -231,11 +228,18 @@
pass
wikipedia.output(u'%s\n\n' % returned_html)
wikipedia.output(u'%i %s' % (response.status, response.reason))
- answer = wikipedia.inputChoice(u'Upload of %s probably failed. Above you see the HTML page which was returned by MediaWiki. Try again?' % filename, ['Yes', 'No'], ['y', 'N'], 'N')
- if answer in ["y", "Y"]:
- return self.upload_image(debug)
+
+ if self.targetSite.mediawiki_message('uploadwarning') in returned_html:
+ answer = wikipedia.inputChoice(u"You have recevied an upload warning message. Ignore?", ['Yes', 'No'], ['y', 'N'], 'N')
+ if answer in ["y", "Y"]:
+ self.ignoreWarning = 1
+ return self.upload_image(debug)
else:
- return
+ answer = wikipedia.inputChoice(u'Upload of %s probably failed. Above you see the HTML page which was returned by MediaWiki. Try again?' % filename, ['Yes', 'No'], ['y', 'N'], 'N')
+ if answer in ["y", "Y"]:
+ return self.upload_image(debug)
+ else:
+ return
return filename
def run(self):