jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/874023 )
Change subject: [bugfix] Use a default result for allusers() if next() leads to StopIteration
......................................................................
[bugfix] Use a default result for allusers() if next() leads to StopIteration
- use a default result for allusers() if next() leads to StopIteration
- catch the NoUsernameError exception in login.py script and only
show the exception message instead of raising it
- fix error messages handling
Bug: T326063
Change-Id: Ia41bc9d80fcfd2e9e88542201236ceab87c6508c
---
M pywikibot/login.py
M pywikibot/scripts/login.py
2 files changed, 28 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/login.py b/pywikibot/login.py
index 1b1b661..e284b98 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -1,6 +1,6 @@
"""Library to log the bot in to a wiki account."""
#
-# (C) Pywikibot team, 2003-2022
+# (C) Pywikibot team, 2003-2023
#
# Distributed under the terms of the MIT license.
#
@@ -133,7 +133,7 @@
try:
data = self.site.allusers(start=main_username, total=1)
- user = next(data)
+ user = next(data, {'name': None})
except APIError as e:
if e.code == 'readapidenied':
pywikibot.warning("Could not check user '{}' exists on {}"
@@ -294,15 +294,16 @@
self.login_to_site()
except APIError as e:
error_code = e.code
- pywikibot.error(f'Login failed ({error_code}).')
+
+ # TODO: investigate other unhandled API codes
if error_code in self._api_error:
- error_msg = 'Username "{}" {} on {}'.format(
+ error_msg = 'Username {!r} {} on {}'.format(
self.login_name, self._api_error[error_code], self.site)
if error_code in ('Failed', 'FAIL'):
- error_msg += f'\n.{e.info}'
+ error_msg += f'.\n{e.info}'
raise NoUsernameError(error_msg)
- # TODO: investigate other unhandled API codes (bug T75539)
+ pywikibot.error(f'Login failed ({error_code}).')
if retry:
self.password = None
return self.login(retry=False)
diff --git a/pywikibot/scripts/login.py b/pywikibot/scripts/login.py
index f47bc20..cbdd9a2 100755
--- a/pywikibot/scripts/login.py
+++ b/pywikibot/scripts/login.py
@@ -47,7 +47,7 @@
moved to :mod:`pywikibot.scripts` folder
"""
#
-# (C) Pywikibot team, 2003-2022
+# (C) Pywikibot team, 2003-2023
#
# Distributed under the terms of the MIT license.
#
@@ -58,7 +58,7 @@
import pywikibot
from pywikibot import config
from pywikibot.backports import Tuple, nullcontext
-from pywikibot.exceptions import SiteDefinitionError
+from pywikibot.exceptions import NoUsernameError, SiteDefinitionError
from pywikibot.login import OauthLoginManager
@@ -109,7 +109,10 @@
if logout:
site.logout()
else:
- site.login(autocreate=autocreate)
+ try:
+ site.login(autocreate=autocreate)
+ except NoUsernameError as e:
+ pywikibot.error(e)
user = site.user()
if user:
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/874023
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: Ia41bc9d80fcfd2e9e88542201236ceab87c6508c
Gerrit-Change-Number: 874023
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/876312 )
Change subject: [doc] Add deprecation of 'cosmetic_changes-append' to ROADMAP.rst
......................................................................
[doc] Add deprecation of 'cosmetic_changes-append' to ROADMAP.rst
'cosmetic_changes-append' were restored but the are still deprecated;
But Pywikibot 7 still needs these messages due to a twtranslation()
bug.
Bug: T326470
Change-Id: Idbe860d64dcaebb6fc367992c5467c78cc6f6224
---
M ROADMAP.rst
1 file changed, 15 insertions(+), 0 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 59ae273..e184105 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -119,6 +119,7 @@
* 7.0.0: A boolean watch parameter in Page.save() is deprecated and will be desupported
* 7.0.0: baserevid parameter of editSource(), editQualifier(), removeClaims(), removeSources(), remove_qualifiers() DataSite methods will be removed
* 7.0.0: Values of APISite.allpages() parameter filterredir other than True, False and None are deprecated
+* 7.0.0: The i18n identifier 'cosmetic_changes-append' will be removed in favour of 'pywikibot-cosmetic-changes'
* 6.5.0: OutputOption.output() method will be removed in favour of OutputOption.out property
* 6.5.0: Infinite rotating file handler with logfilecount of -1 is deprecated
* 6.4.0: 'allow_duplicates' parameter of :func:`tools.itertools.intersect_generators` as positional argument is deprecated, use keyword argument instead
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/876312
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: Idbe860d64dcaebb6fc367992c5467c78cc6f6224
Gerrit-Change-Number: 876312
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/+/876306 )
Change subject: [doc] Allow setting a theme with make.bat
......................................................................
[doc] Allow setting a theme with make.bat
The default furo build needs several minutes to be completed.
This patch enables to use other themes like "basic" od "nature"
to speed up building a documentation. The theme must be added to
the target option like
make html nature
The time usage was also added.
Bug: T322979
Change-Id: I3daa81a12cbeff708cea7cf3334b3199dca2b1b3
---
M docs/make.bat
1 file changed, 56 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/make.bat b/docs/make.bat
index 6726495..7819bc3 100644
--- a/docs/make.bat
+++ b/docs/make.bat
@@ -15,6 +15,10 @@
if "%1" == "" goto help
if "%1" == "help" goto help
+if "%2" == "" goto notheme
+set SPHINXOPTS=%SPHINXOPTS% -D "html_theme=%2"
+:notheme
+
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
@@ -28,14 +32,45 @@
exit /b 1
)
+set STARTTIME=%TIME:~0,8%
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
+set ENDTIME=%TIME:~0,8%
+
+echo Start: %STARTTIME%
+echo End: %ENDTIME%
+
+rem calculate elapsed time, code modified from
+rem https://stackoverflow.com/questions/4487100/how-can-i-use-a-windows-batch-f…
+
+rem convert STARTTIME and ENDTIME to seconds
+set /A STARTTIME=(1%STARTTIME:~0,2%-100)*3600 + (1%STARTTIME:~3,2%-100)*60 + (1%STARTTIME:~6,2%-100)
+set /A ENDTIME=(1%ENDTIME:~0,2%-100)*3600 + (1%ENDTIME:~3,2%-100)*60 + (1%ENDTIME:~6,2%-100)
+
+rem calculating the duratyion is easy
+set /A DURATION=%ENDTIME%-%STARTTIME%
+
+rem we might have measured the time inbetween days
+if %ENDTIME% LSS %STARTTIME% set set /A DURATION=%STARTTIME%-%ENDTIME%
+
+rem now break the seconds down to hors, minutes, seconds
+set /A DURATIONH=%DURATION% / 3600
+set /A DURATIONM=(%DURATION% - %DURATIONH%*3600) / 60
+set /A DURATIONS=(%DURATION% - %DURATIONH%*3600 - %DURATIONM%*60)
+
+rem some formatting
+if %DURATIONH% LSS 10 set DURATIONH=0%DURATIONH%
+if %DURATIONM% LSS 10 set DURATIONM=0%DURATIONM%
+if %DURATIONS% LSS 10 set DURATIONS=0%DURATIONS%
+
+echo Elapsed: %DURATIONH%:%DURATIONM%:%DURATIONS%
+
goto end
:help
echo.
echo make has the following options:
-echo make ^<target^> [^<sphinx options^>]
-echo make html -D "html_theme=basic"
+echo make ^<target^> [^<theme^>]
+echo make html basic
echo.
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR%
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/876306
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: I3daa81a12cbeff708cea7cf3334b3199dca2b1b3
Gerrit-Change-Number: 876306
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged