jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/585005 )
Change subject: [tests] use TestCase for TestPermalink and TestShortLink
......................................................................
[tests] use TestCase for TestPermalink and TestShortLink
- Use TestCase in favour of DefaultSiteTestCase
for TestPermalink and TestShortLink. family and code attributes
is not used with DefaultSiteTestCase except override_default_site
method is called explicitly.
This should solve failing TestShortLink due to not logged in user.
Change-Id: Ic6bef4359a12aef330a88015a226e496928048ec
---
M tests/page_tests.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/page_tests.py b/tests/page_tests.py
index aba1db4..8201445 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -1177,7 +1177,7 @@
self.assertEqual(pywikibot.page.html2unicode('py'), 'py')
-class TestPermalink(DefaultSiteTestCase):
+class TestPermalink(TestCase):
"""Test that permalink links are correct."""
family = 'wikipedia'
@@ -1201,7 +1201,7 @@
'Framawiki%2Fpwb_tests%2Fpermalink&oldid=340685')
-class TestShortLink(DefaultSiteTestCase):
+class TestShortLink(TestCase):
"""Test that short link management is correct."""
user = True
--
To view, visit https://gerrit.wikimedia.org/r/585005
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic6bef4359a12aef330a88015a226e496928048ec
Gerrit-Change-Number: 585005
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/584970 )
Change subject: [doc] Add MaxlagTimeoutError to exceptions doc
......................................................................
[doc] Add MaxlagTimeoutError to exceptions doc
Change-Id: I62f5b6ae50f274d64d452d002f54cc246c17bf2a
---
M pywikibot/exceptions.py
1 file changed, 2 insertions(+), 0 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index 050846e..deca5ea 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -62,6 +62,8 @@
TimeoutError: request failed with a timeout
+ - MaxlagTimeoutError: request failed with a maxlag timeout
+
DeprecationWarning: old functionality replaced by new functionality
PendingDeprecationWarning: problematic code which has not yet been
--
To view, visit https://gerrit.wikimedia.org/r/584970
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I62f5b6ae50f274d64d452d002f54cc246c17bf2a
Gerrit-Change-Number: 584970
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/584907 )
Change subject: [cleanup] Remove disfunctional versionnumber
......................................................................
[cleanup] Remove disfunctional versionnumber
- versionnumber is deprecated for 5 years and disfunctional.
It returns 34 instead of 35 for the current release but
would return 1023 for a mw '2.23.4-wmf.5' which is weird.
It was introduced in compat to compare versions as an int.
Change-Id: Iaec5b758883285f0c37542f6b23ac6982225187e
---
M pywikibot/family.py
1 file changed, 0 insertions(+), 17 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index bea8eaf..ab6f83e 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1369,23 +1369,6 @@
"""
return None
- @deprecated('APISite.version()', since='20141225')
- def versionnumber(self, code):
- """DEPRECATED, use version() instead.
-
- Use L{pywikibot.site.mw_version} to compare version strings.
- Return an int identifying MediaWiki version.
-
- Currently this is implemented as returning the minor version
- number; i.e., 'X' in version '1.X.Y'
- """
- R = re.compile(r'(\d+).(\d+)')
- M = R.search(self.version(code))
- if not M:
- # Version string malformatted; assume it should have been 1.10
- return 10
- return 1000 * int(M.group(1)) + int(M.group(2)) - 1000
-
def encoding(self, code):
"""Return the encoding for a specific language wiki."""
return 'utf-8'
--
To view, visit https://gerrit.wikimedia.org/r/584907
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaec5b758883285f0c37542f6b23ac6982225187e
Gerrit-Change-Number: 584907
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/584920 )
Change subject: [IMPR] Deprecate test family for default site
......................................................................
[IMPR] Deprecate test family for default site
Change-Id: I1562e45b3311e37d47fda0825ed08e30bd277e9d
---
M pywikibot/config2.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 0d08bcc..6f6bed7 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -1148,8 +1148,8 @@
if family == 'wikipedia' and mylang == 'language':
if __no_user_config != '2':
warning('family and mylang are not set.\n'
- "Defaulting to family='test' and mylang='test'.")
- family = mylang = 'test'
+ "Defaulting to family='wikipedia' and mylang='test'.")
+ mylang = 'test'
# Fix up socket_timeout
# Older requests library expect a single value whereas newer versions also
--
To view, visit https://gerrit.wikimedia.org/r/584920
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I1562e45b3311e37d47fda0825ed08e30bd277e9d
Gerrit-Change-Number: 584920
Gerrit-PatchSet: 2
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/584634 )
Change subject: [bugfix] Bail out early if login in progress
......................................................................
[bugfix] Bail out early if login in progress
...as LoginManager handles API errors itself.
Bug: T248768
Change-Id: I4c7eae246a08ca86d92b7fde29689dc70af20126
---
M pywikibot/data/api.py
1 file changed, 4 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 9ca7b81..917287a 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1898,8 +1898,7 @@
def _bad_token(self, code):
"""Check for bad token."""
- if (code != 'badtoken' or self.site._loginstatus
- == pywikibot.site.LoginStatus.IN_PROGRESS):
+ if code != 'badtoken':
return False
user_tokens = self.site.tokens._tokens[self.site.user()]
@@ -1973,7 +1972,9 @@
self._handle_warnings(result)
- if 'error' not in result:
+ # LoginManager handles errors on its own
+ if ('error' not in result or self.site._loginstatus
+ == pywikibot.site.LoginStatus.IN_PROGRESS):
return result
error = result['error'].copy()
--
To view, visit https://gerrit.wikimedia.org/r/584634
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I4c7eae246a08ca86d92b7fde29689dc70af20126
Gerrit-Change-Number: 584634
Gerrit-PatchSet: 3
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/584269 )
Change subject: [bugfix] Fix endless loop when badtoken
......................................................................
[bugfix] Fix endless loop when badtoken
Don't continue with the old login request if badtoken calls new login
using _relogin(). Raise badtoken properly and ask for new token instead.
Also reduce code duplication by creating Request._relogin().
Bug: T248768
Change-Id: I7ec86b94af88dbaa9e720c6e396abba5da507c6d
---
M pywikibot/data/api.py
1 file changed, 13 insertions(+), 14 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 071932a..9ca7b81 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1781,6 +1781,12 @@
self.wait()
return None
+ def _relogin(self, message=''):
+ """Force re-login and inform user."""
+ pywikibot.error('{}{}Forcing re-login.'.format(message,
+ ' ' if message else ''))
+ self.site._relogin()
+
def _userinfo_query(self, result):
"""Handle userinfo query."""
if self.action == 'query' and 'userinfo' in result.get('query', ()):
@@ -1791,11 +1797,9 @@
if (self.site.user() is not None and self.site.user() != username
and self.site._loginstatus
!= pywikibot.site.LoginStatus.IN_PROGRESS):
- pywikibot.error(
- "Logged in as '{actual}' instead of '{expected}'.\n"
- 'Forcing re-login.'.format(actual=username,
- expected=self.site.user()))
- self.site._relogin()
+ message = ("Logged in as '{actual}' instead of '{expected}'."
+ .format(actual=username, expected=self.site.user()))
+ self._relogin(message)
return True
return False
@@ -1836,11 +1840,6 @@
elif code == 'assertuserfailed':
message = 'User assertion failed.'
- # If incorrect login token was used, we are logged out too.
- elif (self.site._loginstatus == pywikibot.site.LoginStatus.IN_PROGRESS
- and code == 'badtoken'):
- message = 'Received incorrect login token.'
-
# Lastly, the purge module requires a POST if used as anonymous user,
# but we normally send a GET request. If the API tells us the request
# has to be POSTed, we're probably logged out.
@@ -1850,8 +1849,7 @@
else:
return True
- pywikibot.error(message + ' Forcing re-login.')
- self.site._relogin()
+ self._relogin(message)
return False
def _internal_api_error(self, code, error, result):
@@ -1900,7 +1898,8 @@
def _bad_token(self, code):
"""Check for bad token."""
- if code != 'badtoken':
+ if (code != 'badtoken' or self.site._loginstatus
+ == pywikibot.site.LoginStatus.IN_PROGRESS):
return False
user_tokens = self.site.tokens._tokens[self.site.user()]
@@ -3165,7 +3164,7 @@
fail_reason = response.get(self.keyword('reason'), '')
if status == self.keyword('success'):
return ''
- elif status in ('NeedToken', 'WrongToken'):
+ elif status in ('NeedToken', 'WrongToken', 'badtoken'):
token = response.get('token')
if token and below_mw_1_27:
# fetched token using action=login
--
To view, visit https://gerrit.wikimedia.org/r/584269
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7ec86b94af88dbaa9e720c6e396abba5da507c6d
Gerrit-Change-Number: 584269
Gerrit-PatchSet: 8
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/584555 )
Change subject: [cleanup] replace deprecated sysopnames in imagetransfer.py
......................................................................
[cleanup] replace deprecated sysopnames in imagetransfer.py
Bug: T71283
Change-Id: I6f64445a4c6e5a73c6ad6e0f117ac88278416e7a
---
M pywikibot/config2.py
M scripts/imagetransfer.py
2 files changed, 2 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 98c489c..0d08bcc 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -898,7 +898,7 @@
# This section contains configuration options that are no longer in use.
# They are kept here to prevent warnings about undefined parameters.
-sysopnames = collections.defaultdict(dict)
+# No obsolete settings currently
# #############################################
diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py
index 2c34142..ac72587 100755
--- a/scripts/imagetransfer.py
+++ b/scripts/imagetransfer.py
@@ -197,9 +197,7 @@
reason = i18n.twtranslate(sourceSite,
'imagetransfer-nowcommons_notice')
# try to delete the original image if we have a sysop account
- if sourceSite.family.name in config.sysopnames \
- and sourceSite.lang in \
- config.sysopnames[sourceSite.family.name]:
+ if sourceSite.has_right('delete'):
if sourceImagePage.delete(reason):
return
if sourceSite.lang in nowCommonsTemplate \
--
To view, visit https://gerrit.wikimedia.org/r/584555
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6f64445a4c6e5a73c6ad6e0f117ac88278416e7a
Gerrit-Change-Number: 584555
Gerrit-PatchSet: 2
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)