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 <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/327551 )
Change subject: Fix regex for error message in siteinfo request
......................................................................
Fix regex for error message in siteinfo request
Allow new format of error message introduced in https://phabricator.wikimedia.org/rMW4e6810e4a
Bug: T153325
Change-Id: I1e2e7dbd711f385fd6ee891f08fa016ddc8fb38c
---
M pywikibot/site.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 92245fd..12a40f4 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1402,8 +1402,8 @@
All values of the siteinfo property 'general' are directly available.
"""
- WARNING_REGEX = re.compile(u"^Unrecognized values? for parameter "
- u"'siprop': ([^,]+(?:, [^,]+)*)$")
+ WARNING_REGEX = re.compile('^Unrecognized values? for parameter '
+ '["\']siprop["\']: (.+?)\.?$')
# Until we get formatversion=2, we have to convert empty-string properties
# into booleans so they are easier to use.
--
To view, visit https://gerrit.wikimedia.org/r/327551
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1e2e7dbd711f385fd6ee891f08fa016ddc8fb38c
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Lokal Profil <lokal.profil(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/326923 )
Change subject: site.py: Adding new warnings 'nochange' and 'duplicateversions'
......................................................................
site.py: Adding new warnings 'nochange' and 'duplicateversions'
It appears only when the uploaded file is duplicate with the
current version or old versions of the file under the same
filename.
The messages are from MediaWiki i18n/en.json
Bug: T153060
Change-Id: I6008bf855d4cbddabcdbd30d9cc9cafd7e87f7c5
---
M pywikibot/site.py
1 file changed, 6 insertions(+), 0 deletions(-)
Approvals:
Magul: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5db67aa..92245fd 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -5930,6 +5930,12 @@
'"%(msg)s".',
'bad-prefix': 'Target filename has a bad prefix %(msg)s.',
'page-exists': 'Target filename exists but with a different file %(msg)s.',
+
+ # API-returned message string will be timestamps, not much use here
+ 'nochange': 'The upload is an exact duplicate of the current version of '
+ 'this file.',
+ 'duplicateversions': 'The upload is an exact duplicate of older '
+ 'version(s) of this file.',
}
# An offset != 0 doesn't make sense without a file key
--
To view, visit https://gerrit.wikimedia.org/r/326923
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6008bf855d4cbddabcdbd30d9cc9cafd7e87f7c5
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>