jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1195385?usp=email )

Change subject: Fixed the watchlist.py counting issue
......................................................................

Fixed the watchlist.py counting issue

Bug: T382708
Change-Id: I1eb3277dfeea1de758b16b5a3e8b336028184f2c
---
M scripts/watchlist.py
1 file changed, 14 insertions(+), 4 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/scripts/watchlist.py b/scripts/watchlist.py
index c6d1a61..b2fb03f 100755
--- a/scripts/watchlist.py
+++ b/scripts/watchlist.py
@@ -25,7 +25,7 @@
    watchlist is retrieved in parallel tasks.
 """
 #
-# (C) Pywikibot team, 2005-2024
+# (C) Pywikibot team, 2005-2025
 #
 # Distributed under the terms of the MIT license.
 #
@@ -38,7 +38,12 @@
 import pywikibot
 from pywikibot import config
 from pywikibot.data.api import CachedRequest
-from pywikibot.exceptions import InvalidTitleError
+from pywikibot.exceptions import (
+    APIError,
+    InvalidTitleError,
+    NoUsernameError,
+    ServerError,
+)
 from pywikibot.tools.threading import BoundedPoolExecutor


@@ -72,8 +77,13 @@
         futures = {executor.submit(refresh, pywikibot.Site(lang, family))
                    for family in config.usernames
                    for lang in config.usernames[family]}
-        wl_count_all = sum(len(future.result())
-                           for future in as_completed(futures))
+        wl_count_all = 0
+        for future in as_completed(futures):
+            try:
+                watchlist_pages = future.result()
+                wl_count_all += len(watchlist_pages)
+            except (NoUsernameError, APIError, ServerError) as e:
+                pywikibot.error(f'Failed to retrieve watchlist: {e}')
     if not quiet:
         pywikibot.info(f'There are a total of {wl_count_all} page(s) in the'
                        ' watchlists for all wikis.')

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1195385?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1eb3277dfeea1de758b16b5a3e8b336028184f2c
Gerrit-Change-Number: 1195385
Gerrit-PatchSet: 6
Gerrit-Owner: Sanjai Siddharthan <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to