jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/971559 )
Change subject: [fix] check for valid family and site option after -help is processed
......................................................................
[fix] check for valid family and site option after -help is processed
pywikibot.handle_args() checks for a valid default site and prints an
error if either the family or the site code is invalid.
Make this test after -help option is processed to avoid unnecessary
api call when -help option is used. This is a workaround unless the
APISite.login(cookie_only=True) call no longer retrieves userinfo in
an early state i.e. instantiating the site.
Bug: T350272
Change-Id: I04a55c96a826c76b5bcf89893be92413985c6429
---
M pywikibot/bot.py
1 file changed, 27 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index d364f6a..2d73000 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -991,15 +991,6 @@
# argument not global -> specific bot script will take care
non_global_args.append(arg)
- if calledModuleName() != 'generate_user_files': # T261771
- try:
- pywikibot.Site()
- except (UnknownFamilyError, UnknownSiteError):
- pywikibot.exception(exc_info=False)
- sys.exit(1)
- if calledModuleName() == 'wrapper':
- pywikibot._sites.clear()
-
if username:
config.usernames[config.family][config.mylang] = username
@@ -1014,6 +1005,15 @@
show_help(show_global=do_help_val == 'global')
sys.exit(0)
+ if calledModuleName() != 'generate_user_files': # T261771
+ try:
+ pywikibot.Site()
+ except (UnknownFamilyError, UnknownSiteError):
+ pywikibot.exception(exc_info=False)
+ sys.exit(1)
+ if calledModuleName() == 'wrapper':
+ pywikibot._sites.clear()
+
debug('handle_args() completed.')
return non_global_args
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/971559
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I04a55c96a826c76b5bcf89893be92413985c6429
Gerrit-Change-Number: 971559
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Martineznovo <martineznovo(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/972505 )
Change subject: [IMPR] Handle canary events in comms.eventstreams
......................................................................
[IMPR] Handle canary events in comms.eventstreams
Handle canary events coming from the Event Platform. Canary events
are periodically sent to check if a stream is working. They contain
bogus data, and should be filtered out by default. See
https://w.wiki/7$2z and https://w.wiki/7$2v for specifics.
This adds a `canary` parameter which enables receiving canary
events. By default, this is set to `False` (canary events are
filtered out). End users can choose to enable this to ensure
that they are still receiving events from EventStreams.
Bug: T350756
Change-Id: Ic7715f5a63af1b00f3a948ce7065373c20cab90d
---
M pywikibot/comms/eventstreams.py
1 file changed, 27 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/eventstreams.py b/pywikibot/comms/eventstreams.py
index 66cba5f..676acbc 100644
--- a/pywikibot/comms/eventstreams.py
+++ b/pywikibot/comms/eventstreams.py
@@ -112,6 +112,8 @@
def __init__(self, **kwargs) -> None:
"""Initializer.
+ :keyword bool canary: if True, include canary events, see
+ https://w.wiki/7$2z for more info
:keyword APISite site: a project site object. Used if no url is
given
:keyword pywikibot.Timestamp or str since: a timestamp for older
@@ -143,6 +145,8 @@
'install it with "pip install sseclient"\n')
self.filter = {'all': [], 'any': [], 'none': []}
self._total = None
+ self._canary = kwargs.pop('canary', False)
+
try:
self._site = kwargs.pop('site')
except KeyError: # T335720
@@ -306,6 +310,9 @@
:param data: event data dict used by filter functions
"""
+ if not self._canary and data.get('meta', {}).get('domain') == 'canary':
+ return False # T266798
+
if any(function(data) for function in self.filter['none']):
return False
if not all(function(data) for function in self.filter['all']):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/972505
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ic7715f5a63af1b00f3a948ce7065373c20cab90d
Gerrit-Change-Number: 972505
Gerrit-PatchSet: 3
Gerrit-Owner: Chlod Alejandro <chlod(a)chlod.net>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged