jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Tokens: Return the csrf token and request correct site
......................................................................
[FIX] Tokens: Return the csrf token and request correct site
This fixes two major problems:
- When a token with the old name is requested (e.g. 'edit') it
uses the new 'csrf' token instead and saves it as an 'csrf' token
in the cache. So the request afterwards must return the 'csrf'
and not 'edit' token (which doesn't exist)
- It must request with the current site and not the default site,
otherwise the default site might return an invalid token or will
emit warnings because it doesn't understand the new API (and the
version check was with the intended and not the default site)
Instead of a warning, it only returns '+\' if the user has not enough
rights with the new token system, so this is dropping all tokens
which only consist of those two letters.
Bug: 70760
Bug: 70766
Change-Id: I38e326c0f5382a585fba11bc6cbfba1a3dffaca5
---
M pywikibot/site.py
1 file changed, 11 insertions(+), 7 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index eb7cf93..4fb586f 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1185,9 +1185,16 @@
def __init__(self, site):
self.site = site
self.site._tokens = {}
+ # TODO: Fetch that from the API with paraminfo
+ self.special_names = set(['deleteglobalaccount', 'patrol', 'rollback',
+ 'setglobalaccountstatus', 'userrights',
+ 'watch'])
def __getitem__(self, key):
storage = self.site._tokens.setdefault(self.site.user(), {})
+ if (LV(self.site.version()) >= LV('1.24wmf19')
+ and key not in self.special_names):
+ key = 'csrf'
if key not in storage:
self.site.preload_tokens([key])
return storage[key]
@@ -2295,20 +2302,17 @@
data = api.Request(site=self, action='tokens',
type='|'.join(types)).submit()
else:
- # TODO: Fetch that from the API with paraminfo
- special_names = set(['deleteglobalaccount', 'patrol', 'rollback',
- 'setglobalaccountstatus', 'userrights',
- 'watch'])
- new_tokens = [token if token in special_names else 'csrf'
+ new_tokens = [token if token in self.tokens.special_names else 'csrf'
for token in types]
- data = api.Request(action='query', meta='tokens',
+ data = api.Request(site=self, action='query', meta='tokens',
type='|'.join(new_tokens)).submit()
if 'query' in data:
data = data['query']
if 'tokens' in data and data['tokens']:
storage.update(dict((key[:-5], val)
- for key, val in data['tokens'].items()))
+ for key, val in data['tokens'].items()
+ if val != '+\\'))
@deprecated("the 'tokens' property")
def token(self, page, tokentype):
--
To view, visit https://gerrit.wikimedia.org/r/159991
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I38e326c0f5382a585fba11bc6cbfba1a3dffaca5
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Travis: Set the number of retries to 2
......................................................................
[IMPROV] Travis: Set the number of retries to 2
To prevent erroring builds because of problems with servers, Travis
shouldn't retry 25 times and wait so long for it that it get's killed.
Change-Id: I94a5c4ae5812f756b1e5f01a4f0d754b2438a1e6
---
M .travis.yml
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.travis.yml b/.travis.yml
index 32df44d..2eee812 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,6 +23,7 @@
- echo "usernames['wikipedia']['test'] = 'Pywikibot-test'" >> ~/.pywikibot/user-config.py
- echo "usernames['wikidata']['test'] = 'Pywikibot-test'" >> ~/.pywikibot/user-config.py
- echo "password_file = os.path.expanduser('~/.pywikibot/passwordfile')" >> ~/.pywikibot/user-config.py
+ - echo "max_retries = 2" >> ~/.pywikibot/user-config.py
- touch ~/.pywikibot/passwordfile
- echo "('Pywikibot-test', '"$USER_PASSWORD"')" > ~/.pywikibot/passwordfile
--
To view, visit https://gerrit.wikimedia.org/r/160000
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I94a5c4ae5812f756b1e5f01a4f0d754b2438a1e6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: retrieve mw version from live wiki for APISite class
......................................................................
retrieve mw version from live wiki for APISite class
- override family method version() for APISite class
- log site.version() which is live version
- remove obsolete version() from WikimediaFamily class because
we use APISite for all wikimedia families and we get the
version information from live wiki
- declare live_version() as deprecated
- test site.version() instead of deprecated live_version()
Change-Id: Icd1c972d5d2deffc60dd78ec3f63b64318ed2d06
---
M pywikibot/bot.py
M pywikibot/family.py
M pywikibot/site.py
M tests/site_tests.py
4 files changed, 22 insertions(+), 13 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index d588612..357bc40 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""User-interface related functions for building bots."""
#
-# (C) Pywikibot team, 2008-2013
+# (C) Pywikibot team, 2008-2014
#
# Distributed under the terms of the MIT license.
#
@@ -315,7 +315,7 @@
if config.log_pywiki_repo_version:
log(u'PYWIKI REPO VERSION: %s' % unicode(version.getversion_onlinerepo()))
- log(u'SITE VERSION: %s' % unicode(site.live_version()))
+ log(u'SITE VERSION: %s' % site.version())
# messages on bot discussion page?
if site.logged_in():
diff --git a/pywikibot/family.py b/pywikibot/family.py
index ad322cd..d2e6a6d 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1087,15 +1087,6 @@
'wikisource', 'wikiversity', 'wiktionary',
]
- def version(self, code):
- """
- Return Wikimedia projects version number as a string.
-
- Use LooseVersion from distutils.version to compate versions.
- """
- # Here we return the latest mw release of wikimedia projects
- return '1.24wmf17'
-
def shared_image_repository(self, code):
return ('commons', 'commons')
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 6e41cc2..eb7cf93 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1210,8 +1210,6 @@
# postForm: Post form data to an address at this site.
# postData: Post encoded form data to an http address at this site.
#
-# version: Return MediaWiki version string from Family file.
-# live_version: Return version number read from Special:Version.
# checkCharset(charset): Warn if charset doesn't match family file.
#
# linktrail: Return regex for trailing chars displayed as part of a link.
@@ -1910,6 +1908,22 @@
lang = property(fget=language, doc=language.__doc__)
+ def version(self):
+ """
+ Return live project version number as a string.
+
+ This overwrites the corresponding family method for APISite class. Use
+ LooseVersion from distutils.version to compare versions.
+ """
+ try:
+ version = self.siteinfo.get('generator', expiry=1).split(' ')[1]
+ except pywikibot.data.api.APIError:
+ # May occur if you are not logged in (no API read permissions).
+ pywikibot.exception(
+ 'You have no API read permissions. Seems you are not logged in')
+ version = self.family.version(self.code)
+ return version
+
@property
def has_image_repository(self):
"""Return True if site has a shared image repository like Commons."""
@@ -1971,6 +1985,7 @@
return self.namespaces()[num]
return self.namespaces()[num][0]
+ @deprecated("version()")
def live_version(self, force=False):
"""Return the 'real' version number found on [[Special:Version]].
diff --git a/tests/site_tests.py b/tests/site_tests.py
index fba6177..f5c8741 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -188,6 +188,9 @@
self.assertIsInstance(mysite.siteinfo, pywikibot.site.Siteinfo)
self.assertIsInstance(mysite.months_names, list)
+ ver = mysite.version()
+ self.assertIsInstance(ver, basestring)
+ self.assertIsNotNone(re.search('^\d+\.\d+.*?\d*$', ver))
self.assertEqual(mysite.list_to_text(('pywikibot',)), 'pywikibot')
def testEnglishSpecificMethods(self):
--
To view, visit https://gerrit.wikimedia.org/r/139102
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icd1c972d5d2deffc60dd78ec3f63b64318ed2d06
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT] Api: Check for every single warning and not all at once
......................................................................
[FEAT] Api: Check for every single warning and not all at once
The warning handler was designed that it's executed for each separate
warning and not for mutliple warnings in the same 'mod'.
Change-Id: I1c4f126487da6db0e460ba7d3d7b6edf5e42b15d
---
M pywikibot/data/api.py
1 file changed, 5 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 229b88a..0e846ae 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -381,9 +381,11 @@
u'API warning ({0})of unknown format: {1}'.
format(mod, warning))
continue
- if (not callable(self._warning_handler) or
- not self._warning_handler(mod, text)):
- pywikibot.warning(u"API warning (%s): %s" % (mod, text))
+ # multiple warnings are in text separated by a newline
+ for single_warning in text.splitlines():
+ if (not callable(self._warning_handler) or
+ not self._warning_handler(mod, single_warning)):
+ pywikibot.warning(u"API warning (%s): %s" % (mod, single_warning))
def submit(self):
"""Submit a query and parse the response.
--
To view, visit https://gerrit.wikimedia.org/r/159944
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1c4f126487da6db0e460ba7d3d7b6edf5e42b15d
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Tokens: Fix getting tokens with the new scheme
......................................................................
[FIX] Tokens: Fix getting tokens with the new scheme
Change-Id: I5b79d02edaf19724ec9c8857f33c57683edb9da6
---
M pywikibot/site.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 1a16e06..6e41cc2 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2281,13 +2281,13 @@
type='|'.join(types)).submit()
else:
# TODO: Fetch that from the API with paraminfo
- special_names = set('deleteglobalaccount', 'patrol', 'rollback',
- 'setglobalaccountstatus', 'userrights',
- 'watch')
+ special_names = set(['deleteglobalaccount', 'patrol', 'rollback',
+ 'setglobalaccountstatus', 'userrights',
+ 'watch'])
new_tokens = [token if token in special_names else 'csrf'
for token in types]
- data = api.Request(action='query',
- tokens='|'.join(new_tokens)).submit()
+ data = api.Request(action='query', meta='tokens',
+ type='|'.join(new_tokens)).submit()
if 'query' in data:
data = data['query']
--
To view, visit https://gerrit.wikimedia.org/r/159947
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5b79d02edaf19724ec9c8857f33c57683edb9da6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Fix random generator handling of no results
......................................................................
Fix random generator handling of no results
If a random generator returns no results, QueryGenerator.__iter__
loops forever.
This was found when running site_tests on test.wikidata.org;
resulting in a travis build breakage in testRandompages
Change-Id: I5e6fde7505a1a2995c58d309233dcb185a69d74a
---
M pywikibot/data/api.py
1 file changed, 3 insertions(+), 0 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index cfc19e3..229b88a 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -927,6 +927,9 @@
# note: self.limit could be -1
if self.limit and self.limit > 0 and count >= self.limit:
return
+ else:
+ # No results.
+ return
if self.module == "random" and self.limit:
# "random" module does not return "query-continue"
# now we loop for a new random query
--
To view, visit https://gerrit.wikimedia.org/r/159921
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5e6fde7505a1a2995c58d309233dcb185a69d74a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: ItemPage class in page.py: correcting default namespace for new items (was ns 0).
......................................................................
ItemPage class in page.py: correcting default namespace for new items (was ns 0).
Change-Id: Ief2caf1ff8ffb5167d11278b54476a2531f6a120
---
M pywikibot/page.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 1ba050e..b0f1259 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -3052,7 +3052,7 @@
"""
# Special case for empty item
if title is None or title == '-1':
- super(ItemPage, self).__init__(site, u'-1', ns=0)
+ super(ItemPage, self).__init__(site, u'-1', ns=site.item_namespace)
self.id = u'-1'
return
--
To view, visit https://gerrit.wikimedia.org/r/159689
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ief2caf1ff8ffb5167d11278b54476a2531f6a120
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Pietrodn <powerpdn(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: upload.py: early detection of site capabilities
......................................................................
upload.py: early detection of site capabilities
If site is not enabled to upload or user han no right, the script quits
immediately.
Bug 69090
Change-Id: I305b4fb18cf87797c551d7978e0f69ffe61cb5db
---
M scripts/upload.py
1 file changed, 15 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/upload.py b/scripts/upload.py
index 65fc037..1418fa2 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -294,6 +294,21 @@
return filename # data['filename']
def run(self):
+
+ # early check that upload is enabled
+ if self.targetSite.is_uploaddisabled():
+ pywikibot.error(
+ "Upload error: Local file uploads are disabled on %s."
+ % self.targetSite)
+ return
+
+ # early check that user has proper rights to upload
+ if "upload" not in self.targetSite.userinfo["rights"]:
+ pywikibot.error(
+ "User '%s' does not have upload rights on site %s."
+ % (self.targetSite.user(), self.targetSite))
+ return
+
while not self.urlOK():
if not self.url:
pywikibot.output(u'No input filename given')
--
To view, visit https://gerrit.wikimedia.org/r/159836
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I305b4fb18cf87797c551d7978e0f69ffe61cb5db
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>