jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1035889?usp=email )
Change subject: [tests] rename environment variable PYWIKIBOT_LOGIN_LOGOUT
......................................................................
[tests] rename environment variable PYWIKIBOT_LOGIN_LOGOUT
rename environment variable PYWIKIBOT_LOGIN_LOGOUT to
PYWIKIBOT_TEST_LOGOUT to be consistent with other test environment
variables. Also add documentation to tests/README.rst.
Change-Id: I4ae5e7ed216aee0023f6270fa918dcbbd93db722
---
M .github/workflows/login_tests-ci.yml
M tests/README.rst
M tests/site_login_logout_tests.py
3 files changed, 14 insertions(+), 4 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/.github/workflows/login_tests-ci.yml b/.github/workflows/login_tests-ci.yml
index bc718bc..dc1de99 100644
--- a/.github/workflows/login_tests-ci.yml
+++ b/.github/workflows/login_tests-ci.yml
@@ -10,8 +10,8 @@
env:
PYWIKIBOT_TEST_RUNNING: 1
+ PYWIKIBOT_TEST_LOGOUT: 1
PYWIKIBOT_USERNAME: Pywikibot-test
- PYWIKIBOT_LOGIN_LOGOUT: 1
jobs:
build:
diff --git a/tests/README.rst b/tests/README.rst
index e6880d0..a6f1265 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -105,6 +105,16 @@
PYWIKIBOT_TEST_GUI=1
+**PYWIKIBOT_TEST_LOGOUT**
+ Used when a test is logging out the test user. This environment variable
+ enables :mod:`tests.site_login_logout_tests`. The environment setting is
+ needed to ensure that these tests run in their own test action and does not
+ interfere with other tests. Otherwise they could fail if the test user is
+ logged out by the test. Only one instance must run this test script. Set this
+ environment variable to run this test locally::
+
+ PYWIKIBOT_TEST_LOGOUT=1
+
**PYWIKIBOT_TEST_MODULES**
Only run tests given with this environment variable. Multiple tests must be
separated by a ``,`` without any white space. Available library tests are
diff --git a/tests/site_login_logout_tests.py b/tests/site_login_logout_tests.py
index 18e0072..c4805c8 100755
--- a/tests/site_login_logout_tests.py
+++ b/tests/site_login_logout_tests.py
@@ -6,7 +6,7 @@
to fail.
"""
#
-# (C) Pywikibot team, 2022-2023
+# (C) Pywikibot team, 2022-2024
#
# Distributed under the terms of the MIT license.
#
@@ -82,8 +82,8 @@
def setUpModule():
- """Skip tests if PYWIKIBOT_LOGIN_LOGOUT variable is not set."""
- if os.environ.get('PYWIKIBOT_LOGIN_LOGOUT', '0') != '1':
+ """Skip tests if PYWIKIBOT_TEST_LOGOUT variable is not set."""
+ if os.environ.get('PYWIKIBOT_TEST_LOGOUT', '0') != '1':
raise unittest.SkipTest('login/logout tests are disabled')
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1035889?usp=email
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: I4ae5e7ed216aee0023f6270fa918dcbbd93db722
Gerrit-Change-Number: 1035889
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
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/+/1035864?usp=email )
Change subject: Revert "[IMPR] use CachedRequest for userinfo requests"
......................................................................
Revert "[IMPR] use CachedRequest for userinfo requests"
This reverts commit 07adfba14c901e46a4c794c3b4f5ad673a7f7885.
Bug: T348925
Bug: T365942
Change-Id: Ie8e34ff2678d5f548b05b796895dc3264689f45b
---
M ROADMAP.rst
M pywikibot/config.py
M pywikibot/site/_apisite.py
3 files changed, 5 insertions(+), 15 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/ROADMAP.rst b/ROADMAP.rst
index e42e037..30a077d 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,7 +1,6 @@
Current release
---------------
-* Use :class:`data.api.CachedRequest` for userinfo requests (:phab:`T348925`)
* Raise :exc:`exceptions.SectionError` if a section does not exists on a page (:phab:`T107141`)
* Retry api request on ServerError (:phab:`T364275`, :phab:`T364393`)
diff --git a/pywikibot/config.py b/pywikibot/config.py
index b2f20fb..7f12bcc 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -175,8 +175,6 @@
site_interface = 'APISite'
# number of days to cache namespaces, api configuration, etc.
API_config_expiry = 30
-# userinfo expiry
-API_uinfo_expiry = 1
# The maximum number of bytes which uses a GET request, if not positive
# it'll always use POST requests
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 0fe76de..729a7ec 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -648,10 +648,6 @@
.. seealso:: :api:`Userinfo`
.. versionchanged:: 8.0
Use API formatversion 2.
- .. versionchanged:: 9.2
- API call is made through :class:`data.api.CachedRequest` with
- expiry is set in ``API_uinfo_expiry`` within
- :ref:`Account settings`.
:return: A dict with the following keys and values:
@@ -665,14 +661,11 @@
"""
if not hasattr(self, '_userinfo'):
- uirequest = self._request(
- expiry=pywikibot.config.API_uinfo_expiry,
- parameters={
- 'action': 'query',
- 'meta': 'userinfo',
- 'uiprop': 'blockinfo|hasmsg|groups|rights|ratelimits',
- 'formatversion': 2,
- }
+ uirequest = self.simple_request(
+ action='query',
+ meta='userinfo',
+ uiprop='blockinfo|hasmsg|groups|rights|ratelimits',
+ formatversion=2,
)
uidata = uirequest.submit()
assert 'query' in uidata, \
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1035864?usp=email
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: Ie8e34ff2678d5f548b05b796895dc3264689f45b
Gerrit-Change-Number: 1035864
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
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/+/1035856?usp=email )
Change subject: [doc] Update ROADMAP.rst
......................................................................
[doc] Update ROADMAP.rst
Change-Id: I15e336058996b0aeca8e7b978416592920afc702
---
M ROADMAP.rst
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index d1ef503..e42e037 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,13 +1,14 @@
Current release
---------------
+* Use :class:`data.api.CachedRequest` for userinfo requests (:phab:`T348925`)
* Raise :exc:`exceptions.SectionError` if a section does not exists on a page (:phab:`T107141`)
* Retry api request on ServerError (:phab:`T364275`, :phab:`T364393`)
Deprecations
------------
-* 9.2.0: *total* argument in ``-logevents`` pagegenrators option is deprecated;
+* 9.2.0: *total* argument in ``-logevents`` pagegenerators option is deprecated;
use ``-limit`` instead (:phab:`T128981`)
* 9.0.0: The *content* parameter of :meth:`proofreadpage.IndexPage.page_gen` is deprecated and will be ignored
(:phab:`T358635`)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1035856?usp=email
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: I15e336058996b0aeca8e7b978416592920afc702
Gerrit-Change-Number: 1035856
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
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/+/1034059?usp=email )
Change subject: [IMPR] use CachedRequest for userinfo requests
......................................................................
[IMPR] use CachedRequest for userinfo requests
The expiry for userinfo is set to 1 day and can be changed within
user-config.py file. The second call for the same userinfo is upto
50 times faster.
Also create the site within its own worker thread. Now preload_sites.py
is up to 90 times faster than before and only half as fast than pwb 8.
Bug: T348925
Change-Id: I2bc6c375ee9b676e0a40a372362f37ee4a61ced8
---
M pywikibot/config.py
M pywikibot/scripts/preload_sites.py
M pywikibot/site/_apisite.py
3 files changed, 35 insertions(+), 12 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config.py b/pywikibot/config.py
index 7f12bcc..b2f20fb 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -175,6 +175,8 @@
site_interface = 'APISite'
# number of days to cache namespaces, api configuration, etc.
API_config_expiry = 30
+# userinfo expiry
+API_uinfo_expiry = 1
# The maximum number of bytes which uses a GET request, if not positive
# it'll always use POST requests
diff --git a/pywikibot/scripts/preload_sites.py b/pywikibot/scripts/preload_sites.py
index 8ff7d57..27a31f7 100755
--- a/pywikibot/scripts/preload_sites.py
+++ b/pywikibot/scripts/preload_sites.py
@@ -6,13 +6,18 @@
-worker:<num> The number of parallel tasks to be run. Default is the
number of processors on the machine
-Usage::
+**Usage:**
python pwb.py preload_sites [{<family>}] [-worker:{<num>}]
-To force preloading, change the global expiry value to 0::
+To force preloading, change the global expiry values to 0:
- python pwb.py -API_config_expiry:0 preload_sites [{<family>}]
+ python pwb.py -API_config_expiry:0 -API_uinfo_expiry:0 \
+ preload_sites [{<family>}]
+
+or run the :mod:`cache<scripts.maintenance.cache>` script previeously:
+
+ python pwb.py cache -delete
.. versionchanged:: 7.4
script was moved to the framework scripts folder.
@@ -57,7 +62,17 @@
def preload_family(family: str, executor: ThreadPoolExecutor) -> None:
- """Preload all sites of a single family file."""
+ """Preload all sites of a single family file.
+
+ .. versionchanged:: 9.2
+ use a separate worker thread for each site.
+ """
+
+ def create_page(code, family):
+ """Preload siteinfo and userinfo."""
+ site = pywikibot.Site(code, family)
+ pywikibot.Page(site, 'Main Page')
+
msg = 'Preloading sites of {} family{}'
pywikibot.info(msg.format(family, '...'))
@@ -65,14 +80,13 @@
for code in exceptions.get(family, []):
if code in codes:
codes.remove(code)
+
obsolete = Family.load(family).obsolete
futures = set()
for code in codes:
if code not in obsolete:
- site = pywikibot.Site(code, family)
- # page title does not care
- futures.add(executor.submit(pywikibot.Page, site, 'Main page'))
+ futures.add(executor.submit(create_page, code, family))
wait(futures)
pywikibot.info(msg.format(family, ' completed.'))
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 729a7ec..0fe76de 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -648,6 +648,10 @@
.. seealso:: :api:`Userinfo`
.. versionchanged:: 8.0
Use API formatversion 2.
+ .. versionchanged:: 9.2
+ API call is made through :class:`data.api.CachedRequest` with
+ expiry is set in ``API_uinfo_expiry`` within
+ :ref:`Account settings`.
:return: A dict with the following keys and values:
@@ -661,11 +665,14 @@
"""
if not hasattr(self, '_userinfo'):
- uirequest = self.simple_request(
- action='query',
- meta='userinfo',
- uiprop='blockinfo|hasmsg|groups|rights|ratelimits',
- formatversion=2,
+ uirequest = self._request(
+ expiry=pywikibot.config.API_uinfo_expiry,
+ parameters={
+ 'action': 'query',
+ 'meta': 'userinfo',
+ 'uiprop': 'blockinfo|hasmsg|groups|rights|ratelimits',
+ 'formatversion': 2,
+ }
)
uidata = uirequest.submit()
assert 'query' in uidata, \
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1034059?usp=email
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: I2bc6c375ee9b676e0a40a372362f37ee4a61ced8
Gerrit-Change-Number: 1034059
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
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/+/1033678?usp=email )
Change subject: [cleanup] remove arguments cleanup introduced with pwb 6.0.0
......................................................................
[cleanup] remove arguments cleanup introduced with pwb 6.0.0
Change-Id: I1ccc08b60e126397377707569cb31040bd9697cd
---
M scripts/solve_disambiguation.py
1 file changed, 4 insertions(+), 74 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index ac7f4ad..26c1dae 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -75,7 +75,7 @@
"""
#
-# (C) Pywikibot team, 2003-2023
+# (C) Pywikibot team, 2003-2024
#
# Distributed under the terms of the MIT license.
#
@@ -107,7 +107,7 @@
NoPageError,
PageSaveRelatedError,
)
-from pywikibot.tools import first_lower, first_upper, issue_deprecation_warning
+from pywikibot.tools import first_lower, first_upper
from pywikibot.tools.formatter import SequenceOutputter
@@ -610,7 +610,7 @@
}
# refer -help message for complete options documentation
- disambig_options = {
+ available_options = {
'always': None, # always perform the same action
'pos': [], # add possibilities as alternative disambig
'just': True, # just and only use the possibilities given with command
@@ -621,83 +621,13 @@
'min': 0, # minimum number of pages on a disambig
}
- # needed for argument cleanup
- available_options = disambig_options
-
def __init__(self, *args, **kwargs) -> None:
"""Initializer."""
- self._clean_args(args, kwargs)
- super().__init__(**kwargs)
+ super().__init__(*args, **kwargs)
self.ignores = set()
self.summary = None
self.dn_template_str = i18n.translate(self.site, dn_template)
- def _clean_args(self, args, kwargs) -> None:
- """Cleanup positional and keyword arguments.
-
- Replace positional arguments with keyword arguments.
- Replace old keywords with new keywords which are given by
- argument handling.
-
- This also fixes arguments which aren't currently used by
- BaseDisambigBot abstract class but was introduced for the old
- DisambiguationRobot to prevent multiple deprecation warnings.
- """
- # New keys of positional arguments
- keys = ('always', 'pos', 'just', 'dnskip', 'generator', 'primary',
- 'main', 'first', 'min')
-
- # Keys mapping from old argument name to new keywords.
- # The ordering of dics is not safe for Python < 3.7. Therefore
- # we need a dict in addition to key above.
- keymap = {
- 'alternatives': 'pos',
- 'getAlternatives': 'just',
- 'dnSkip': 'dnskip',
- 'main_only': 'main',
- 'first_only': 'first',
- 'minimum': 'min',
- }
-
- # Replace positional arguments with keyword arguments
- for i, arg in enumerate(args):
- key = keys[i]
- issue_deprecation_warning(
- f'Positional argument {i + 1} ({arg})',
- f'keyword argument "{key}={arg}"',
- since='6.0.0')
- if key in kwargs:
- pywikibot.warning('{!r} is given as keyword argument {!r} '
- 'already; ignoring {!r}'
- .format(key, arg, kwargs[key]))
- else:
- kwargs[key] = arg
-
- # replace old keywords to new
- for key in list(kwargs):
- if key in keymap:
- newkey = keymap[key]
- issue_deprecation_warning(
- f'{key!r} argument of {self.__class__.__name__}',
- repr(newkey), since='6.0.0')
- kwargs[newkey] = kwargs.pop(key)
-
- # Expand available_options
- # Currently scripts may have its own options set
- added_keys = []
- for key in keys:
- if key != 'generator' and key not in self.available_options:
- added_keys.append(key)
- self.available_options[key] = self.disambig_options[key]
- if added_keys:
- pywikibot.warning("""\
-The following keys were added to available_options:
-{options}.
-Either add them to available_options setting of {classname}
-bot class or use available_options.update() to use default settings from
-DisambiguationRobot""".format(options=added_keys,
- classname=self.__class__.__name__))
-
def checkContents(self, text: str) -> str | None: # noqa: N802
"""
Check if the text matches any of the ignore regexes.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1033678?usp=email
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: I1ccc08b60e126397377707569cb31040bd9697cd
Gerrit-Change-Number: 1033678
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <dalangi-ctr(a)wikimedia.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged