jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/446695 )
Change subject: newitem.py: disable touching pages for non autoconfirmed
......................................................................
newitem.py: disable touching pages for non autoconfirmed
Touching pages triggers edits on pages, that can hit throttle
rates and captachas.
The default behavior is to touch only pages linked to newly
created items. Now touch system will be disabled completely
if user is not autoconfirmed, to avoid interruptions.
It's still possible to force touching pages by using -touch
option.
Note that nothing is implemented yet to allow non autoconfirmed
to touch only pages linked to newly created items, it's only
binary in this case.
Bug: T199936
Change-Id: Ib536542049ae16be0bd62d911522fad91acaeac4
---
M scripts/newitem.py
1 file changed, 19 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/newitem.py b/scripts/newitem.py
index c3c3f6b..a2f3595 100755
--- a/scripts/newitem.py
+++ b/scripts/newitem.py
@@ -16,6 +16,8 @@
created.
-touch Do a null edit on every page which has a wikibase item.
+ Be careful, this option can trigger edit rates or captachas
+ if your account is not autoconfirmed.
"""
#
@@ -27,6 +29,7 @@
from __future__ import absolute_import, division, unicode_literals
from datetime import timedelta
+from textwrap import fill
import pywikibot
from pywikibot import pagegenerators, WikidataBot
@@ -46,7 +49,8 @@
'always': True,
'lastedit': 7,
'pageage': 21,
- 'touch': False,
+ 'touch': 'newly', # Can be False, newly (pages linked to
newly
+ # created items) or True (touch all pages)
})
super(NewItemRobot, self).__init__(**kwargs)
@@ -68,6 +72,7 @@
@staticmethod
def _touch_page(page):
try:
+ pywikibot.output('Doing a null edit on the page.')
page.touch()
except (NoCreateError, NoPage):
pywikibot.error('Page {0} does not exist.'.format(
@@ -80,7 +85,7 @@
page.title(as_link=True)))
def _callback(self, page, exc):
- if exc is None:
+ if exc is None and self.getOption('touch'):
self._touch_page(page)
def treat_page_and_item(self, page, item):
@@ -88,8 +93,7 @@
if item and item.exists():
pywikibot.output('{0} already has an item: {1}.'
.format(page, item))
- if self.getOption('touch'):
- pywikibot.output('Doing a null edit on the page.')
+ if self.getOption('touch') is True:
self._touch_page(page)
return
@@ -152,6 +156,17 @@
return False
bot = NewItemRobot(generator, **options)
+ user = pywikibot.User(bot.site, bot.site.username)
+ if bot.getOption('touch') == 'newly' \
+ and 'autoconfirmed' not in user.groups():
+ pywikibot.warning(fill(
+ 'You are logged in as {}, an account that is '
+ 'not in the autoconfirmed group on {}. Script '
+ 'will not touch pages linked to newly created '
+ 'items to avoid triggering edit rates or '
+ 'captachas. Use -touch param to force this.'
+ .format(user.username, bot.site.sitename)))
+ bot.options['touch'] = False
bot.run()
return True
--
To view, visit
https://gerrit.wikimedia.org/r/446695
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib536542049ae16be0bd62d911522fad91acaeac4
Gerrit-Change-Number: 446695
Gerrit-PatchSet: 7
Gerrit-Owner: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: Bugreporter <bugreporter1(a)sina.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)