http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10409
Revision: 10409
Author: xqt
Date: 2012-06-22 10:06:02 +0000 (Fri, 22 Jun 2012)
Log Message:
-----------
syncronize maxquerysize with pagegenerators.PreloadingGenerator step value
Modified Paths:
--------------
branches/rewrite/scripts/interwiki.py
Modified: branches/rewrite/scripts/interwiki.py
===================================================================
--- branches/rewrite/scripts/interwiki.py 2012-06-21 22:52:43 UTC (rev 10408)
+++ branches/rewrite/scripts/interwiki.py 2012-06-22 10:06:02 UTC (rev 10409)
@@ -300,7 +300,7 @@
interwiki_min_subjects
-query: The maximum number of pages that the bot will load at once.
- Default value is 60.
+ Default value is 50.
Some configuration option can be used to change the working of this robot:
@@ -457,7 +457,7 @@
force = False
cleanup = False
remove = []
- maxquerysize = 60
+ maxquerysize = 50
same = False
skip = set()
skipauto = False
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10405
Revision: 10405
Author: xqt
Date: 2012-06-21 22:30:10 +0000 (Thu, 21 Jun 2012)
Log Message:
-----------
fixes infinite loop while self.data exists and now new request is done
Modified Paths:
--------------
branches/rewrite/pywikibot/data/api.py
Modified: branches/rewrite/pywikibot/data/api.py
===================================================================
--- branches/rewrite/pywikibot/data/api.py 2012-06-21 18:19:05 UTC (rev 10404)
+++ branches/rewrite/pywikibot/data/api.py 2012-06-21 22:30:10 UTC (rev 10405)
@@ -685,6 +685,7 @@
if isinstance(value, int):
value = str(value)
self.request[key] = value
+ del self.data # a new request with query-continue is needed
def result(self, data):
"""Process result data as needed for particular subclass."""
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10403
Revision: 10403
Author: xqt
Date: 2012-06-21 13:03:17 +0000 (Thu, 21 Jun 2012)
Log Message:
-----------
-simulate option for rewrite branch
Modified Paths:
--------------
branches/rewrite/pywikibot/bot.py
branches/rewrite/pywikibot/config2.py
branches/rewrite/pywikibot/data/api.py
Modified: branches/rewrite/pywikibot/bot.py
===================================================================
--- branches/rewrite/pywikibot/bot.py 2012-06-21 10:37:49 UTC (rev 10402)
+++ branches/rewrite/pywikibot/bot.py 2012-06-21 13:03:17 UTC (rev 10403)
@@ -252,6 +252,7 @@
text = unicode(text, 'iso8859-1')
logger.log(_level, text, extra=context, **kwargs)
+
def output(text, decoder=None, newline=True, toStdout=False, **kwargs):
"""Output a message to the user via the userinterface.
@@ -431,6 +432,8 @@
elif arg == '-nolog':
if moduleName in config.log:
config.log.remove(moduleName)
+ elif arg == '-simulate':
+ config.simulate = True
#
# DEBUG control:
#
Modified: branches/rewrite/pywikibot/config2.py
===================================================================
--- branches/rewrite/pywikibot/config2.py 2012-06-21 10:37:49 UTC (rev 10402)
+++ branches/rewrite/pywikibot/config2.py 2012-06-21 13:03:17 UTC (rev 10403)
@@ -516,6 +516,16 @@
# Configuration variable 'socks' is defined but unknown. Misspelled?proxy = None
proxy = None
+### Simulate settings ###
+# Defines what actions the bots are NOT allowed to do (e.g. 'edit') on wikipedia
+# servers. Allows simulation runs of bots to be carried out without changing any
+# page on the server side. This setting may be overridden in user_config.py.
+actions_to_block = ['edit', 'watch', 'move', 'delete', 'undelete', 'protect',
+ 'emailuser']
+
+# Set simulate to True or use -simulate option to block all actions given above.
+simulate = False
+
# How many pages should be put to a queue in asynchroneous mode.
# If maxsize is <= 0, the queue size is infinite.
# Increasing this value will increase memory space but could speed up
Modified: branches/rewrite/pywikibot/data/api.py
===================================================================
--- branches/rewrite/pywikibot/data/api.py 2012-06-21 10:37:49 UTC (rev 10402)
+++ branches/rewrite/pywikibot/data/api.py 2012-06-21 13:03:17 UTC (rev 10403)
@@ -200,6 +200,13 @@
+ self.http_params()
)
+ def _simulate(self, action):
+ if action and config.simulate and action in config.actions_to_block:
+ pywikibot.output(
+ u'\03{lightyellow}SIMULATION: %s action blocked.\03{default}'
+ % action)
+ return {action: {'result': 'Success', 'nochange': ''}}
+
def submit(self):
"""Submit a query and parse the response.
@@ -213,6 +220,9 @@
paramstring = self.http_params()
while True:
action = self.params.get("action", "")
+ simulate = self._simulate(action)
+ if simulate:
+ return simulate
self.site.throttle(write=self.write)
uri = self.site.scriptpath() + "/api.php"
try: