jenkins-bot has submitted this change and it was merged.
Change subject: Use Pillow instead of PIL in setup.py
......................................................................
Use Pillow instead of PIL in setup.py
PIL stopped working in travis builds.
It works correctly under setuptools 5.7, but fails under setuptools 3.3
Rather than force a setuptools upgrade on everyone, use Pillow.
'PIL is not setuptools compatible.'
http://pillow.readthedocs.org/en/latest/about.html#why-a-fork
Remove the apt-get of python-imaging-tk, which previously
installed PIL.
'System Python is not used and should not be relied on.'
http://docs.travis-ci.com/user/languages/python/
Change-Id: Ic437462da8b637ce17a333c19a62b02a63474a07
---
M .travis.yml
M setup.py
2 files changed, 2 insertions(+), 2 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.travis.yml b/.travis.yml
index 96983cf..32df44d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,7 @@
before_install:
- sudo apt-get update -qq
- - sudo apt-get install -y python-imaging-tk liblua5.1-dev
+ - sudo apt-get install -y liblua5.1-dev
install:
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install ordereddict unittest2; fi
diff --git a/setup.py b/setup.py
index 422561e..86102fb 100644
--- a/setup.py
+++ b/setup.py
@@ -23,7 +23,7 @@
script_deps = {
'script_wui.py': ['irc', 'lunatic-python', 'crontab'],
# Note: None of the 'lunatic-python' repos on github support MS Windows.
- 'flickrripper.py': ['PIL', 'flickrapi'],
+ 'flickrripper.py': ['Pillow', 'flickrapi'],
# Note: 'PIL' is not available via pip2.7 on MS Windows,
# however it is available with setuptools.
}
--
To view, visit https://gerrit.wikimedia.org/r/159207
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic437462da8b637ce17a333c19a62b02a63474a07
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT] Add mandatory docstring tests
......................................................................
[FEAT] Add mandatory docstring tests
Currently the docstring tests are not mandatory. Because with any
change there is a chance that new PEP 257 errors are introduced it's
hard to make them mandatory, because all errors need to be fixed at
once. This change should make it easier as particular files can be
fixed from PEP 257 errors and then added to the mandatory list. If
now any later change introduces an error, it will fail the test on
already fixed files.
This adds only the test environment for tox but not actually adds
the test, which needs to be done separately.
All files which are PEP 257 compliant (except family files) are
already added.
Change-Id: I3e34ecc56996d58ace96299ceaf63a2278055fcb
---
M tox.ini
1 file changed, 7 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tox.ini b/tox.ini
index 3022ca6..ddecf62 100644
--- a/tox.ini
+++ b/tox.ini
@@ -23,6 +23,13 @@
# See upstream issue:
# https://bitbucket.org/tarek/flake8/issue/167/flake8-223-stall-with-multipro…
+[testenv:flake8-docstrings-mandatory]
+# Add any new file which is pep257 compatible
+commands = flake8 --jobs=1 --ignore=D102,D103,E122,E127,E241,E265 \
+ ./pywikibot/echo.py ./pywikibot/config2.py ./pywikibot/weblib.py \
+ ./pywikibot/fixes.py ./pywikibot/editor.py ./pywikibot/comms/http.py \
+ ./pywikibot/compat/userlib.py ./pywikibot/compat/catlib.py
+deps = flake8-docstrings
[testenv:nose]
setenv = PYWIKIBOT2_NO_USER_CONFIG=1
--
To view, visit https://gerrit.wikimedia.org/r/159073
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3e34ecc56996d58ace96299ceaf63a2278055fcb
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: fileIsShared fails on sites with shared file repo
......................................................................
fileIsShared fails on sites with shared file repo
"missing" exists in page dict when the file is shared.
KeyError occurs for file on a shared repo if the file
is not a local file. To prevent KeyError, check if
'imageinfo' exists first, then if 'missing' exists
the page does not exist.
Bug: 70494
Change-Id: I2cfbbd2434cb03600c9d53e648e0534f05756d46
---
M pywikibot/page.py
M pywikibot/site.py
M tests/file_tests.py
3 files changed, 9 insertions(+), 9 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 1fc54eb..5484370 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1860,8 +1860,6 @@
# TODO: put the URLs to family file
if not self.site.has_image_repository:
return False
- elif not self.exists():
- raise pywikibot.NoPage(self)
elif 'wikitravel_shared' in self.site.shared_image_repository():
return self.fileUrl().startswith(
u'http://wikitravel.org/upload/shared/')
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 6825a26..b520fef 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -33,6 +33,7 @@
from pywikibot.data import api
from pywikibot.exceptions import (
Error,
+ PageRelatedError,
PageSaveRelatedError,
EditConflict,
PageCreatedConflict,
@@ -2017,12 +2018,13 @@
u"loadimageinfo: Query on %s returned data on '%s'"
% (page, pageitem['title']))
api.update_page(page, pageitem)
- if "missing" in pageitem:
- raise pywikibot.NoPage(page)
if "imageinfo" not in pageitem:
- raise Error(
- u"loadimageinfo: Query on %s returned no imageinfo"
- % page)
+ if "missing" in pageitem:
+ raise NoPage(page)
+
+ raise PageRelatedError(
+ page,
+ u"loadimageinfo: Query on %s returned no imageinfo")
return (pageitem['imageinfo']
if history else pageitem['imageinfo'][0])
diff --git a/tests/file_tests.py b/tests/file_tests.py
index 7e83d0b..dc4a3b3 100644
--- a/tests/file_tests.py
+++ b/tests/file_tests.py
@@ -28,11 +28,11 @@
self.assertFalse(itwp_file.exists())
self.assertTrue(commons_file.exists())
- self.assertRaises(pywikibot.NoPage, itwp_file.fileIsShared)
+ self.assertTrue(itwp_file.fileIsShared())
self.assertTrue(commons_file.fileIsShared())
self.assertTrue(commons_file.fileUrl())
- self.assertRaises(pywikibot.NoPage, itwp_file.fileUrl)
+ self.assertIn('/wikipedia/commons/', itwp_file.fileUrl())
self.assertRaises(pywikibot.NoPage, itwp_file.get)
def testLocalOnly(self):
--
To view, visit https://gerrit.wikimedia.org/r/158921
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2cfbbd2434cb03600c9d53e648e0534f05756d46
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Deprecate SSL override configuration
......................................................................
Deprecate SSL override configuration
No sites use this functionality, as wikimedia sites changed from
a https://secure.wikimedia.org front-end processor to using https
on the target wiki.
Also remove the 'ssl' override parameter from http.request.
The ssl param was only used with the site parameter, to support the
configuration variables, and was ignored if a uri was provided.
Change-Id: I5834ca17972e888886d15524098331cd8839f1da
---
M pywikibot/comms/http.py
M pywikibot/config2.py
M pywikibot/data/api.py
M tests/dry_api_tests.py
4 files changed, 56 insertions(+), 26 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 25af2a1..f2f6eaa 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -62,6 +62,7 @@
from pywikibot import config
from pywikibot.exceptions import FatalServerError, Server504Error
from pywikibot.comms import threadedhttp
+from pywikibot.tools import deprecate_arg
import pywikibot.version
_logger = "comm.http"
@@ -204,29 +205,33 @@
return formatted
-def request(site, uri, ssl=False, *args, **kwargs):
+@deprecate_arg('ssl', None)
+def request(site=None, uri=None, *args, **kwargs):
"""Queue a request to be submitted to Site.
All parameters not listed below are the same as
- L{httplib2.Http.request}, but the uri is relative
+ L{httplib2.Http.request}.
- If the site argument is None the uri has to be absolute and is
- taken. In this case SSL is ignored. Used for requests to non wiki
- pages.
+ If the site argument is provided, the uri is relative to the site's
+ scriptpath.
+
+ If the site argument is None, the uri must be absolute, and is
+ used for requests to non wiki pages.
@param site: The Site to connect to
- @param uri: the URI to retrieve (relative to the site's scriptpath)
- @param ssl: Use HTTPS connection
+ @type site: L{pywikibot.site.Site}
+ @param uri: the URI to retrieve
+ @type uri: str
@return: The received data (a unicode string).
"""
+ assert(site or uri)
if site:
- if ssl:
- proto = "https"
+ proto = site.protocol()
+ if proto == 'https':
host = site.ssl_hostname()
uri = site.ssl_pathprefix() + uri
else:
- proto = site.protocol()
host = site.hostname()
baseuri = urlparse.urljoin("%s://%s" % (proto, host), uri)
else:
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 4da09e9..b021a05 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -38,6 +38,8 @@
# to other modules.
_private_values = ['authenticate', 'proxy', 'db_password']
+_deprecated_variables = ['use_SSL_onlogin', 'use_SSL_always',
+ 'available_ssl_project_comment']
# ############# ACCOUNT SETTINGS ##############
@@ -103,17 +105,15 @@
authenticate = {}
#
-# Security Connection for Wikimedia Projects
+# Secure connection overrides
#
+# These settings are deprecated. They existed to support the Wikimedia
+# family which only served HTTPS on https://secure.wikimedia.org/<site>/<uri>
+# Use Family.protocol()
use_SSL_onlogin = False # if available, use SSL when logging in
use_SSL_always = False # if available, use SSL for all API queries
-
-# Available security projects
-available_ssl_project = [
- u'wikipedia', u'wikinews', u'wikisource', u'wiktionary', u'wikibooks',
- u'wikiquote', u'wikiversity', u'meta', u'mediawiki', u'commons',
- u'species', u'incubator'
-]
+# Available secure projects should be listed here.
+available_ssl_project = []
# By default you are asked for a password on the terminal.
# A password file may be used. e.g. password_file = ".passwd"
@@ -786,6 +786,10 @@
for _key in _modified:
globals()[_key] = _uc[_key]
+ if _key in _deprecated_variables:
+ print("WARNING: '%s' is no longer a supported configuration variable."
+ "\nPlease inform the maintainers if you depend on it." % _key)
+
# Fix up default console_encoding
if console_encoding is None:
if sys.platform == 'win32':
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 2810150..cfc19e3 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -79,6 +79,25 @@
pass
+class EnableSSLSiteWrapper(object):
+ """Wrapper to change the site protocol to https."""
+
+ def __init__(self, site):
+ self._site = site
+
+ def __repr__(self):
+ return repr(self._site)
+
+ def __eq__(self, other):
+ return self._site == other
+
+ def __getattr__(self, attr):
+ return getattr(self._site, attr)
+
+ def protocol(self):
+ return 'https'
+
+
class Request(MutableMapping):
"""A request to a Site's api.php interface.
@@ -190,6 +209,11 @@
self.site.has_extension('AssertEdit'))):
pywikibot.debug(u"Adding user assertion", _logger)
self.params["assert"] = "user" # make sure user is logged in
+
+ if (self.site.protocol() == 'http' and (config.use_SSL_always or (
+ self.params["action"] == "login" and config.use_SSL_onlogin))
+ and self.site.family.name in config.available_ssl_project):
+ self.site = EnableSSLSiteWrapper(self.site)
# implement dict interface
def __getitem__(self, key):
@@ -378,12 +402,6 @@
else:
pywikibot.log("Action '{0}' is submitted not throttled.".format(action))
uri = self.site.scriptpath() + "/api.php"
- ssl = False
- if self.site.family.name in config.available_ssl_project:
- if action == "login" and config.use_SSL_onlogin:
- ssl = True
- elif config.use_SSL_always:
- ssl = True
try:
if self.mime:
# construct a MIME message containing all API key/values
@@ -412,10 +430,10 @@
body = body[eoh + len(marker):]
# retrieve the headers from the MIME object
mimehead = dict(list(container.items()))
- rawdata = http.request(self.site, uri, ssl, method="POST",
+ rawdata = http.request(self.site, uri, method="POST",
headers=mimehead, body=body)
else:
- rawdata = http.request(self.site, uri, ssl, method="POST",
+ rawdata = http.request(self.site, uri, method="POST",
headers={'Content-Type': 'application/x-www-form-urlencoded'},
body=paramstring)
# import traceback
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index de448c6..83dac6e 100644
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -73,6 +73,9 @@
def version(self):
return '1.13' # pre 1.14
+ def protocol(self):
+ return 'http'
+
def languages(self):
return ['mock']
--
To view, visit https://gerrit.wikimedia.org/r/153298
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5834ca17972e888886d15524098331cd8839f1da
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(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: 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] Support new token system
......................................................................
[FEAT] Support new token system
With fdddf94570efc33fd06f16c72d41636a45cf203a the token system was
overhauled. This queries with the new token system if the version
is new enough (>= 1.24wmf19).
If the token type is not one of the listed in the api help it is
defaulting to 'csrf'.
Bug: 70060
Change-Id: I54fc1d7ad083f12b80ef52ddb7be592fa82b6b2a
---
M pywikibot/site.py
1 file changed, 26 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 07a280c..7216d7e 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2191,7 +2191,17 @@
"""Preload one or multiple tokens.
For all MediaWiki versions prior to 1.20, only one token can be
- retrieved at once.
+ retrieved at once. For MediaWiki versions since 1.24wmfXXX a new token
+ system was introduced which reduced the amount of tokens available.
+ Most of them were merged into the 'csrf' token. If the token type in
+ the parameter is not known it'll default to the 'csrf' token. The other
+ token types available are:
+ - deleteglobalaccount
+ - patrol
+ - rollback
+ - setglobalaccountstatus
+ - userrights
+ - watch
@param types: the types of token (e.g., "edit", "move", "delete");
see API documentation for full list of types
@@ -2209,8 +2219,21 @@
if (tokentype + 'token') in item:
storage[tokentype] = item[tokentype + 'token']
else:
- data = api.Request(site=self, action='tokens',
- type='|'.join(types)).submit()
+ if LV(self.version()) < LV('1.24wmf19'):
+ 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'
+ for token in types]
+ data = api.Request(action='query',
+ tokens='|'.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()))
--
To view, visit https://gerrit.wikimedia.org/r/156463
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I54fc1d7ad083f12b80ef52ddb7be592fa82b6b2a
Gerrit-PatchSet: 3
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: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>