jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/351325 )
Change subject: Accept QuitKeyboardInterrupt in specialbots.Uploadbot
......................................................................
Accept QuitKeyboardInterrupt in specialbots.Uploadbot
- call Bot.exit() when script terminates
- Adjust _treat_counter and _save_counter
Bug: T163970
Change-Id: Icfd50925bfea739316b405b63f7066ff83ed4eb5
---
M pywikibot/specialbots.py
1 file changed, 21 insertions(+), 5 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/specialbots.py b/pywikibot/specialbots.py
index bd6c4d2..232e7e3 100644
--- a/pywikibot/specialbots.py
+++ b/pywikibot/specialbots.py
@@ -21,7 +21,7 @@
from pywikibot import config
-from pywikibot.bot import BaseBot
+from pywikibot.bot import BaseBot, QuitKeyboardInterrupt
from pywikibot.tools import PY2, deprecated
from pywikibot.tools.formatter import color_format
@@ -439,6 +439,7 @@
if success:
# No warning, upload complete.
pywikibot.output(u"Upload of %s successful." % filename)
+ self._save_counter += 1
return filename # data['filename']
else:
pywikibot.output(u"Upload aborted.")
@@ -459,7 +460,22 @@
"User '%s' does not have upload rights on site %s."
% (self.targetSite.user(), self.targetSite))
return
- if isinstance(self.url, basestring):
- return self.upload_file(self.url)
- for file_url in self.url:
- self.upload_file(file_url)
+
+ try:
+ if isinstance(self.url, basestring):
+ self._treat_counter = 1
+ return self.upload_file(self.url)
+ for file_url in self.url:
+ self.upload_file(file_url)
+ self._treat_counter += 1
+ except QuitKeyboardInterrupt:
+ pywikibot.output('\nUser quit %s bot run...' %
+ self.__class__.__name__)
+ except KeyboardInterrupt:
+ if config.verbose_output:
+ raise
+ else:
+ pywikibot.output('\nKeyboardInterrupt during %s bot run...' %
+ self.__class__.__name__)
+ finally:
+ self.exit()
--
To view, visit
https://gerrit.wikimedia.org/r/351325
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icfd50925bfea739316b405b63f7066ff83ed4eb5
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>