jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/589843 )
Change subject: [bugfix] Use Bot.userPut() method to handle PageSaveRelatedError ......................................................................
[bugfix] Use Bot.userPut() method to handle PageSaveRelatedError
- Use Bot.userPut() method to handle PageSaveRelatedError This method is called by a local save method to simplify the parameters - always use asynchronous parameter, otherwise it will be set depending on "always" option - userPut has its own user_confirm() method. Rewrite it and just return True
Bug: T205205 Change-Id: I1f447a3767a447e144e35d43112eff9b388ffff5 --- M scripts/replace.py 1 file changed, 17 insertions(+), 21 deletions(-)
Approvals: Huji: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py index d358ff8..ab361b9 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -810,11 +810,10 @@ if choice == 'a': self.options['always'] = True if choice == 'y': - page.text = new_text - page.save(summary=self.generate_summary(applied), - asynchronous=True, + self.save(page, original_text, new_text, applied, + show_diff=False, quiet=True, callback=self._replace_async_callback, - quiet=True) + asynchronous=True) while not self._pending_processed_titles.empty(): proc_title, res = self._pending_processed_titles.get() pywikibot.output('Page {0}{1} saved' @@ -824,23 +823,10 @@ break
if self.getOption('always') and new_text != original_text: - try: - page.text = new_text - page.save(summary=self.generate_summary(applied), - callback=self._replace_sync_callback, quiet=True) - except pywikibot.EditConflict: - pywikibot.output('Skipping {0} because of edit conflict' - .format(page.title(),)) - except pywikibot.SpamfilterError as e: - pywikibot.output( - 'Cannot change {0} because of blacklist entry {1}' - .format(page.title(), e.url)) - except pywikibot.LockedPage: - pywikibot.output('Skipping {0} (locked page)' - .format(page.title(),)) - except pywikibot.PageNotSaved as error: - pywikibot.output('Error putting page: {0}' - .format(error.args,)) + self.save(page, original_text, new_text, applied, + show_diff=False, quiet=True, + callback=self._replace_sync_callback, + asynchronous=False) if self._pending_processed_titles.qsize() > 50: while not self._pending_processed_titles.empty(): proc_title, res = self._pending_processed_titles.get() @@ -848,6 +834,16 @@ .format(proc_title, '' if res else ' not'))
+ def save(self, page, oldtext, newtext, applied, **kwargs): + """Save the given page.""" + self.userPut(page, oldtext, newtext, + summary=self.generate_summary(applied), + ignore_save_related_errors=True, **kwargs) + + def user_confirm(self, question): + """Always return True due to our own input choice.""" + return True +
def prepareRegexForMySQL(pattern): """Convert regex to MySQL syntax."""