Revision: 5487
Author: filnik
Date: 2008-05-31 19:16:48 +0000 (Sat, 31 May 2008)
Log Message:
-----------
The regex as example currently doesn't work, fixing it
Modified Paths:
--------------
trunk/pywikipedia/add_text.py
Modified: trunk/pywikipedia/add_text.py
===================================================================
--- trunk/pywikipedia/add_text.py 2008-05-31 19:06:30 UTC (rev 5486)
+++ trunk/pywikipedia/add_text.py 2008-05-31 19:16:48 UTC (rev 5487)
@@ -27,7 +27,7 @@
# Command used on it.wikipedia to put the template in the page without any category.
# But warning! Put it in a line, otherwise it won't work correctly.
-python add_text.py -excepturl:"<p class='catlinks'>" -uncat -text:"{{Categorizzare}}"
+python add_text.py -excepturl:"class='catlinks'>" -uncat -text:"{{Categorizzare}}"
-except:"\{\{([Tt]emplate:|)[Cc]ategorizzare" -summary:"Bot: Aggiungo template Categorizzare"
--- Credits and Help ---
Patches item #1980786, was opened at 2008-05-31 17:01
Message generated for change (Comment added) made by filnik
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1980786&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: Closed
Resolution: None
Priority: 5
Private: No
Submitted By: Uberfuzzy (uberfuzzy)
>Assigned to: Filnik (filnik)
Summary: add_text.py using page.put not put_async
Initial Comment:
Index: add_text.py
===================================================================
--- add_text.py (revision 5485)
+++ add_text.py (working copy)
@@ -195,7 +195,7 @@
return (False, always)
if choice == 'y' or always:
try:
- page.put(newtext, summary)
+ page.put_async(newtext, summary)
except wikipedia.EditConflict:
wikipedia.output(u'Edit conflict! skip!')
return (False, always)
----------------------------------------------------------------------
>Comment By: Filnik (filnik)
Date: 2008-05-31 19:09
Message:
Logged In: YES
user_id=1834469
Originator: NO
Done, according to the way done on replace.py (using the normal put if you
set -always as True).
So, Fixed in the revision 5486.
Filnik
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1980786&group_…
Revision: 5486
Author: filnik
Date: 2008-05-31 19:06:30 +0000 (Sat, 31 May 2008)
Log Message:
-----------
Adding put_async for the manual mode, letting it for the auto mode
Modified Paths:
--------------
trunk/pywikipedia/add_text.py
Modified: trunk/pywikipedia/add_text.py
===================================================================
--- trunk/pywikipedia/add_text.py 2008-05-31 16:26:29 UTC (rev 5485)
+++ trunk/pywikipedia/add_text.py 2008-05-31 19:06:30 UTC (rev 5486)
@@ -25,6 +25,8 @@
python add_text.py -cat:catname -summary:"Bot: Adding a template" -text:"{{Something}}" -except:"\{\{([Tt]emplate:|)[Ss]omething" -up
# Command used on it.wikipedia to put the template in the page without any category.
+# But warning! Put it in a line, otherwise it won't work correctly.
+
python add_text.py -excepturl:"<p class='catlinks'>" -uncat -text:"{{Categorizzare}}"
-except:"\{\{([Tt]emplate:|)[Cc]ategorizzare" -summary:"Bot: Aggiungo template Categorizzare"
@@ -195,7 +197,10 @@
return (False, always)
if choice == 'y' or always:
try:
- page.put(newtext, summary)
+ if always:
+ page.put(newtext, summary)
+ else:
+ page.put_async(newtext, summary)
except wikipedia.EditConflict:
wikipedia.output(u'Edit conflict! skip!')
return (False, always)
Bugs item #1980786, was opened at 2008-05-31 13:01
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1980786&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: Uberfuzzy (uberfuzzy)
Assigned to: Nobody/Anonymous (nobody)
Summary: add_text.py using page.put not put_async
Initial Comment:
Index: add_text.py
===================================================================
--- add_text.py (revision 5485)
+++ add_text.py (working copy)
@@ -195,7 +195,7 @@
return (False, always)
if choice == 'y' or always:
try:
- page.put(newtext, summary)
+ page.put_async(newtext, summary)
except wikipedia.EditConflict:
wikipedia.output(u'Edit conflict! skip!')
return (False, always)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1980786&group_…
Revision: 5483
Author: filnik
Date: 2008-05-31 13:43:31 +0000 (Sat, 31 May 2008)
Log Message:
-----------
Fixing some fixMes let by NicDumZ. Commenting except badtitle for testing purpose to catch it in a better way... but to tell the truth, I think it's not a good idea :P let's try btw.
Modified Paths:
--------------
trunk/pywikipedia/welcome.py
Modified: trunk/pywikipedia/welcome.py
===================================================================
--- trunk/pywikipedia/welcome.py 2008-05-31 11:34:17 UTC (rev 5482)
+++ trunk/pywikipedia/welcome.py 2008-05-31 13:43:31 UTC (rev 5483)
@@ -390,9 +390,7 @@
def parselog(wsite, raw, talk, number):
""" The function to load the users (only users who have a certain number of edits) """
- #FIXME : Why is there a need for this 'done' list ? We're not even checking for duplicates...
- done = list()
-
+ someone_found = False
autocreated = wsite.mediawiki_message('newuserlog-autocreate-entry')
# I search with a regex how many user have not the talk page
@@ -406,9 +404,8 @@
p = re.compile(reg, re.UNICODE)
for x in p.finditer(raw):
+ someone_found = True
username = x.group('user')
- if username not in done:
- done.append(username)
#skip autocreated users (SUL)
if autocreated in x.group('reason'):
wikipedia.output(u'%s has been created automatically, skipping...' % username)
@@ -422,6 +419,7 @@
#FIXME: It counts the first 50 edits
# if number > 50, it won't work
+ # (not *so* useful, it should be enough).
contribnum = contribs.count('<li>')
if contribnum >= number:
@@ -436,7 +434,7 @@
# That user mustn't be welcomed.
continue
- if len(done) == 0:
+ if someone_found:
wikipedia.output(u'There is nobody to be welcomed...')
else:
wikipedia.output(u'\nLoaded all users...')
@@ -778,10 +776,6 @@
whitelist_default = list()
# Join the whitelist words.
whitelist = list_white + whitelist_default
- # List of words that the bot understands when it asks the operator for input.
- block = ("B", "b", "Blocco", "blocco", "block", "bloc", "Block", "Bloc", 'Report', 'report')
- say_hi = ("S", "s", "Saluto", "saluto", "Welcome", "welcome", 'w', 'W', 'say hi',
- 'Say hi', 'Hi', 'hi', 'h', 'hello', 'Hello')
# think about non-wikimedia wikis. Use Site functions.
URL = wsite.log_address(limit, 'newusers')
@@ -830,64 +824,54 @@
# Understand if the user has a bad-username.
username = str(username).encode(config.console_encoding)
lower_uname = username.lower()
- for word in elenco:
+ for word in elenco: # elenco = list of bad words
if word.lower() in lower_uname:
baduser = True
- # What's this ? Docu please.
+ # The format of the italian report template is:
+ # {{Reported|NICKNAME|BADWORD}}
+ # The nickname is already added before and
+ # here we add the "badword" part, but
+ # this function is used only in the italian wiki.
if wsite.lang == 'it':
final_rep = "%s%s}}" % (rep_text, word)
break
else:
final_rep = rep_text
break
- # Checking in the whitelist...
-
- # FIXME I believe this is broken
+ # Checking in the whitelist...
for xy in whitelist:
if xy.lower() in lower_uname:
- # the next line does *not* change username
- # besides replacing xy is useless if only xy.lower()
- # is in username
- lower_uname.replace(xy, '')
+ # Deleting the white word found and check
+ # the word that remains for badwords inside.
+ lower_uname = lower_uname.replace(xy, '')
for word in elenco:
baduser = word.lower() in lower_uname
break
# He has a badusername, trying to report him...
if baduser:
- # FIXME : while 1 ? What the... ? Do we need a while here ? Documentation please.
- while 1:
- if ask:
- wikipedia.output(u'%s may have an unwanted username, what shall I do?' % usertalkpage.titleWithoutNamespace())
-
- # FIXME : consider using inputChoice here
-
- answer = wikipedia.input(u'[B]lock or [W]elcome?')
- for w in block:
- if w in answer:
- if not usertalkpage.exists():
- # Check if the user has been already blocked (second check).
- if blocked(wsite, username):
- wikipedia.output(u'%s has been blocked! Skipping him...' % usertalkpage.titleWithoutNamespace())
- # FIXME: that continue will continue on "for w in block:". Do we really want to do this ?
- continue
- report(wsite, rep_page, username, com, final_rep)
- break
- else:
- wikipedia.output(u'The discussion page of the bad-user already exists...')
- running = False
- #FIXME : Why don't we break here ?
- for w in say_hi:
- if w in answer:
- baduser = False
- break
- else:
- wikipedia.output(u'%s is possibly an unwanted username. He will be reported.' % usertalkpage.titleWithoutNamespace())
+ if ask:
+ answer = wikipedia.inputChoice(u'%s may have an unwanted username, do you want to report this user?'
+ % usertalkpage.titleWithoutNamespace(), ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
+ if answer.lower() in ['yes', 'y']:
if not usertalkpage.exists():
+ # Check if the user has been already blocked (second check).
+ if blocked(wsite, username):
+ wikipedia.output(u'%s has been blocked! Skipping him...' % usertalkpage.titleWithoutNamespace())
report(wsite, rep_page, username, com, final_rep)
- break
+ continue
else:
wikipedia.output(u'The discussion page of the bad-user already exists...')
- break
+ continue
+ if answer.lower() in ['no', 'n', 'nope']:
+ baduser = False
+ else:
+ wikipedia.output(u'%s is possibly an unwanted username. He will be reported.' % usertalkpage.titleWithoutNamespace())
+ if not usertalkpage.exists():
+ report(wsite, rep_page, username, com, final_rep)
+ continue
+ else:
+ wikipedia.output(u'The discussion page of the bad-user already exists...')
+ continue
# He has a good username, welcome!
else:
if not usertalkpage.exists():
@@ -944,34 +928,32 @@
time.sleep(time_variable)
# If not recursive, break.
elif recursive == False:
- #FIXME : others "yields" yield a single integer. Why are we doing this here ? 'STOP' is not even being retrieved
- yield [number_user, 'STOP']
+ yield number_user
+ break
if __name__ == "__main__":
# Use try and finally, to put the wikipedia.stopme() always at the end of the code.
try:
- 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.
- #FIXME: Do we need to do this ?
- # in other words, why can't main() return a SINGLE value,
- # an integer, number_user ?
- for x in main(settingsBot):
- try:
- number_user = x[0]
- except TypeError:
- number_user = x
- else:
- break
- except wikipedia.BadTitle:
- #FIXME : This kind of error should be catched earlier.
- wikipedia.output(u"Wikidown or server's problem. Quit.")
- wikipedia.stopme()
+ #try:
+ number_user = 0
+ 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.
+ # If recursive, just wait some error or something to get the number
+ # and save it, otherwise just save the first one.
+ for number_user in main(settingsBot):
+ pass # number_user get with the for cicle the value
+ #except wikipedia.BadTitle:
+ # If the server is down, pywikipediabot raise that error.
+ # Better to catch it in order not to get useless errors
+ # (in particular if you're running that script on toolserver).
+ # FixME: put this except in a better "place" (next to the part
+ # that raises the error)
+ # 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 and savedata and number_user != None:
Revision: 5482
Author: nicdumz
Date: 2008-05-31 11:34:17 +0000 (Sat, 31 May 2008)
Log Message:
-----------
erm. Fixing weblinkchecker.py : a "not" was missing :/
Modified Paths:
--------------
trunk/pywikipedia/weblinkchecker.py
Modified: trunk/pywikipedia/weblinkchecker.py
===================================================================
--- trunk/pywikipedia/weblinkchecker.py 2008-05-31 10:54:25 UTC (rev 5481)
+++ trunk/pywikipedia/weblinkchecker.py 2008-05-31 11:34:17 UTC (rev 5482)
@@ -477,7 +477,7 @@
# read the server's encoding, in case we need it later
self.readEncodingFromResponse(response)
# site down if the server status is between 400 and 499
- alive = response.status in range(400, 500)
+ alive = response.status not in range(400, 500)
if response.status in self.HTTPignore:
alive = False
return alive, '%s %s' % (response.status, response.reason)
I can't login anymore using login.py on wikimedia sites. This is, I
think, because of the recent changes with Global Auth / SUL.
This is not an immediate issue, because we can actually all use our
bots, given that our cookies dont expire. But with time this is going
to be annoying.
On a timeline aspect, Darkoneko told me that login.py was working
yesterday morning, so this is quite recent.
So far, I can give you an HTTP response on a login (given that the
right password is entered) :
Date: Fri, 30 May 2008 15:58:11 GMT
Server: Apache
X-Powered-By: PHP/5.2.1
Cache-Control: private, s-maxage=0, max-age=0, must-revalidate
Set-Cookie: frwiki_session=xxxxxxxxxxxxxxxxxxx; path=/; HttpOnly
Set-Cookie: frwikiUserID=280295; expires=Sun, 29-Jun-2008 15:58:11
GMT; path=/; httponly
Set-Cookie: frwikiUserName=DumZiBoT; expires=Sun, 29-Jun-2008 15:58:11
GMT; path=/; httponly
Vary: Accept-Encoding,Cookie
X-Vary-Options:
Accept-Encoding;list-contains=gzip,Cookie;string-contains=frwikiToken;string-contains=frwikiLoggedOut;string-contains=frwiki_session;string-contains=centralauth_Token;string-contains=centralauth_Session;string-contains=centralauth_LoggedOut
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Location: http://fr.wikipedia.org/w/index.php?title=Special:Connexion&wpCookieCheck=l…
Content-Encoding: gzip
Content-Length: 20
Content-Type: text/html; charset=utf-8
X-Cache: MISS from sq24.wikimedia.org
X-Cache-Lookup: MISS from sq24.wikimedia.org:3128
X-Cache: MISS from knsq29.knams.wikimedia.org
X-Cache-Lookup: MISS from knsq29.knams.wikimedia.org:3128
X-Cache: MISS from knsq25.knams.wikimedia.org
X-Cache-Lookup: MISS from knsq25.knams.wikimedia.org:80
Via: 1.0 sq24.wikimedia.org:3128 (squid/2.6.STABLE18), 1.0
knsq29.knams.wikimedia.org:3128 (squid/2.6.STABLE18), 1.0
knsq25.knams.wikimedia.org:80 (squid/2.6.STABLE18)
Connection: close
We are given 3 cookies, but we previously expected one more cookie,
frwikiToken, which is not available on the HTTP answer. Previously,
when all the cookies werent sent back, we searched for a captcha in
the page and sent again the post data with the captcha answer to
retrieve the entire cookie.
However, here, there is no page content. The HTTP response is a 302,
page temporarily moved, and the relocaton - from the header - is
http://fr.wikipedia.org/w/index.php?title=Special:Connexion&wpCookieCheck=l…
I don't know what is needed here : I tried retrieving that second
page, and unsurprisingly, the HTTP response is a 403 forbidden, likely
because I need to send along some data. The question is : what data
exactly is needed ? Send again the same post data ?
X-vary-options mentions the missing cookie, frwikiToken, do you know
what is that header entry ? Google searches return squid issues (and
funny thing, patches from Tim Starling) : is it relevant here ?
About squids, I consider the cache MISSes as normal, because squids
can't handle login information, and just redirect us to a login
server. Am I right on this one ?
Any help on this is welcome, I failed finding any related mediawiki
documentation.
Most of all, if someone finds a fix, I'd really be interested by the
walkthrough : I'm quite lost with that problem, not exactly knowing
what I should test / try / check. And I need to learn how to do this
:þ
--
Nicolas Dumazet — NicDumZ [ nIk.d̪ymz ]
Deuxième année ENSIMAG.