jenkins-bot has submitted this change and it was merged.
Change subject: Bug 69039 - welcome raises exception if site is not configured ......................................................................
Bug 69039 - welcome raises exception if site is not configured
welcome.py checks if site is managed by the script, otherwise exit without error is site is not managed by the script and show help.
Change-Id: I8a7ce9a6442841a897ec2e4854f5e80bfe5c781f --- M scripts/welcome.py 1 file changed, 31 insertions(+), 2 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved XZise: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/scripts/welcome.py b/scripts/welcome.py index 529984e..0456bf6 100644 --- a/scripts/welcome.py +++ b/scripts/welcome.py @@ -433,9 +433,13 @@
class WelcomeBot(object):
+ """Bot to add welcome messages on User pages.""" + def __init__(self): - #Initial + """Constructor.""" + self.site = pywikibot.Site() + self.check_managed_sites() self.bname = dict()
self._totallyCount = 0 @@ -445,6 +449,23 @@ self.defineSign(True) if __name__ != '__main__': # use only in module call self._checkQueue = [] + + def check_managed_sites(self): + """Check that site is managed by welcome.py.""" + # Raises KeyError if site is not in netext with right family. + try: + site_netext = netext[self.site.family.name] + except KeyError: + raise KeyError( + u'Site %s not managed by welcome.py: family "%s" missing in netext.' + % (self.site, self.site.family.name)) + # Raises KeyError if site is not in netext with language. + try: + site_netext = site_netext[self.site.code] + except KeyError: + raise KeyError( + u'Site %s not managed by welcome.py: lang "%s" missing in netext[%s].' + % (self.site, self.site.code, self.site.family.name))
def badNameFilter(self, name, force=False): if not globalvar.filtBadName: @@ -950,7 +971,15 @@ pywikibot.warning( 'both -offset and -timeoffset were provided, ignoring -offset') globalvar.offset = 0 - bot = WelcomeBot() + + try: + bot = WelcomeBot() + except KeyError as error: + # site not managed by welcome.py + pywikibot.showHelp() + pywikibot.warning(error) + return + try: bot.run() except KeyboardInterrupt:
pywikibot-commits@lists.wikimedia.org