jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/625720 )

Change subject: [IMPR] Print login status to log file if 'badtoken' API error 
occures
......................................................................

[IMPR] Print login status to log file if 'badtoken' API error occures

Bug: T261050
Change-Id: Idf69faf2fdb4e77242bd76bbfd97f4c40f28e99a
---
M pywikibot/data/api.py
1 file changed, 16 insertions(+), 12 deletions(-)

Approvals:
  Matěj Suchánek: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 4c896fd..9063528 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1870,8 +1870,12 @@
 
     def _bad_token(self, code) -> bool:
         """Check for bad token."""
-        if (code != 'badtoken' or self.site._loginstatus
-                == pywikibot.site.LoginStatus.IN_PROGRESS):
+        if code != 'badtoken':  # Other code not handled here
+            return False
+
+        if self.site._loginstatus == pywikibot.site.LoginStatus.IN_PROGRESS:
+            pywikibot.log('Login status: {}'
+                          .format(self.site._loginstatus.name))
             return False

         user_tokens = self.site.tokens._tokens[self.site.user()]
@@ -1897,16 +1901,16 @@
             for name, t_type in invalid_param.items():
                 self[name] = self.site.tokens[t_type]
             return True
-        else:
-            # otherwise couldn't find any … weird there is nothing what
-            # can be done here because it doesn't know which parameters
-            # to fix
-            pywikibot.log(
-                'Bad token error for {} but no parameter is using a '
-                'token. Current tokens: {}'
-                .format(self.site.user(),
-                        ', '.join('{}: {}'.format(*e)
-                                  for e in user_tokens.items())))
+
+        # otherwise couldn't find any … weird there is nothing what
+        # can be done here because it doesn't know which parameters
+        # to fix
+        pywikibot.log(
+            'Bad token error for {} but no parameter is using a '
+            'token. Current tokens: {}'
+            .format(self.site.user(),
+                    ', '.join('{}: {}'.format(*e)
+                              for e in user_tokens.items())))
         return False

     def submit(self) -> dict:

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/625720
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: Idf69faf2fdb4e77242bd76bbfd97f4c40f28e99a
Gerrit-Change-Number: 625720
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: Multichill <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to