jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/206790 )
Change subject: Use user-based configuration settings in script_wui.py
......................................................................
Use user-based configuration settings in script_wui.py
And also a nice error message when it doesn't exist.
Bug: T70797
Change-Id: I7486e66df0c05b490f1e8cc95c28b74e370fe90a
---
M scripts/script_wui.py
1 file changed, 19 insertions(+), 12 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/script_wui.py b/scripts/script_wui.py
index 616e35f..ba75271 100755
--- a/scripts/script_wui.py
+++ b/scripts/script_wui.py
@@ -73,7 +73,6 @@
import datetime
import gc
import logging
-import os
import re
import resource
import sys
@@ -107,14 +106,11 @@
bot_config = {
- 'BotName':
pywikibot.config.usernames[pywikibot.config.family][pywikibot.config.mylang],
+ 'BotName': "{username}",
- # protected !!! ('CSS' or other semi-protected page is essential here)
- 'ConfCSSshell': 'User:DrTrigon/DrTrigonBot/script_wui-shell.css',
- 'ConfCSScrontab':
u'User:DrTrigon/DrTrigonBot/script_wui-crontab.css',
-
- # (may be protected but not that important... 'CSS' is not needed here !!!)
- 'ConfCSSoutput': u'User:DrTrigonBot/Simulation',
+ 'ConfCSSshell': u'User:{username}/script_wui-shell.css',
+ 'ConfCSScrontab': u'User:{username}/script_wui-crontab.css',
+ 'ConfCSSoutput': u'User:{username}/Simulation',
'CRONMaxDelay': 5 * 60.0, # check all ~5 minutes
@@ -157,15 +153,20 @@
}
pywikibot.output(u'** Pre-loading all relevant page contents')
for item in self.refs:
- # security; first check if page is protected, reject any data if not
- if os.path.splitext(self.refs[item].title().lower())[1] not in
['.css', '.js']:
+ # First check if page is protected, reject any data if not
+ parts = self.refs[item].title().lower().rsplit('.')
+ if len(parts) == 1 or parts[1] not in ['.css', '.js']:
raise ValueError(u'%s config %s = %s is not a secure page; '
u'it should be a css or js userpage which are '
u'automatically semi-protected.'
% (self.__class__.__name__, item,
self.refs[item]))
- self.refs[item].get(force=True) # load all page contents
-
+ try:
+ self.refs[item].get(force=True) # load all page contents
+ except pywikibot.NoPage:
+ pywikibot.error("The configuation page %s doesn't exists"
+ % self.refs[item].title(asLink=True))
+ raise
# init background timer
pywikibot.output(u'** Starting crontab background timer thread')
self.on_timer()
@@ -326,6 +327,12 @@
site = pywikibot.Site()
site.login()
chan = '#' + site.code + '.' + site.family.name
+
+ bot_user_name =
pywikibot.config.usernames[pywikibot.config.family][pywikibot.config.mylang]
+ for key, value in bot_config.items():
+ if hasattr(value, 'format'):
+ bot_config[key] = value.format(username=bot_user_name)
+
bot = ScriptWUIBot(site, chan, site.user() + "_WUI",
"irc.wikimedia.org")
try:
bot.start()
--
To view, visit
https://gerrit.wikimedia.org/r/206790
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7486e66df0c05b490f1e8cc95c28b74e370fe90a
Gerrit-PatchSet: 8
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Pppery <mapreader(a)olum.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>