Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2532
Status: Fixed
Duration: 24 minutes and 9 seconds
Commit: 4bd04db (master)
Author: Fabian Neundorf
Message: [FIX] checkimages: Expect NoPage exception
In compat the script called `getHash` which returned None if the image is
missing while `latest_file_info` raises a NoPage exception.
The script was previously fixed in 88ad247f and the usage was changed into
`getFileSHA1Sum` which would raise a `TypeError` if the page doesn't exist.
Bug: T105727
Change-Id: I9c39c41b86125ab7eeb1e842faad2a2cecbcb637
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/08eec2d832f3...4bd04db5…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/70875982
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] checkimages: Expect NoPage exception
......................................................................
[FIX] checkimages: Expect NoPage exception
In compat the script called `getHash` which returned None if the image is
missing while `latest_file_info` raises a NoPage exception.
The script was previously fixed in 88ad247f and the usage was changed into
`getFileSHA1Sum` which would raise a `TypeError` if the page doesn't exist.
Bug: T105727
Change-Id: I9c39c41b86125ab7eeb1e842faad2a2cecbcb637
---
M scripts/checkimages.py
1 file changed, 3 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index cd6514a..627a1a7 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -905,8 +905,9 @@
"""Checking if the file is on commons."""
pywikibot.output(u'Checking if [[%s]] is on commons...'
% self.imageName)
- hash_found = self.image.latest_file_info.sha1
- if not hash_found:
+ try:
+ hash_found = self.image.latest_file_info.sha1
+ except pywikibot.NoPage:
return # Image deleted, no hash found. Skip the image.
site = pywikibot.Site('commons', 'commons')
--
To view, visit https://gerrit.wikimedia.org/r/224589
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9c39c41b86125ab7eeb1e842faad2a2cecbcb637
Gerrit-PatchSet: 2
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] page: Return unicode timestamps
......................................................................
[FIX] page: Return unicode timestamps
The timestamps in compat are returned directly from the API which are parsed as
unicode instances. When 81d5291b returned several Timestamp instances now as
strings it uses Timestamp.isoformat() which returns bytes in Python 2 so they
need to be converted into unicode.
Change-Id: I92ef76a9988b6cccb42fffdd52a224850337ec49
---
M pywikibot/page.py
1 file changed, 4 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 7ea7337..4c91b02 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1578,7 +1578,7 @@
@rtype: tuple(username, Timestamp)
"""
result = self.oldest_revision
- return result.user, result.timestamp.isoformat()
+ return result.user, unicode(result.timestamp.isoformat())
@deprecated('contributors() or revisions()')
@deprecated_args(limit="total")
@@ -1590,7 +1590,7 @@
@param total: iterate no more than this number of revisions in total
@rtype: list of dict, each dict containing the username and Timestamp
"""
- return [{'user': rev.user, 'timestamp': rev.timestamp.isoformat()}
+ return [{'user': rev.user, 'timestamp': unicode(rev.timestamp.isoformat())}
for rev in self.revisions(total=total)]
@deprecate_arg("throttle", None)
@@ -2230,7 +2230,7 @@
"""
return [self.oldest_file_info.user,
- self.oldest_file_info.timestamp.isoformat()]
+ unicode(self.oldest_file_info.timestamp.isoformat())]
@deprecated("FilePage.latest_file_info.user")
def getLatestUploader(self):
@@ -2240,7 +2240,7 @@
"""
return [self.latest_file_info.user,
- self.latest_file_info.timestamp.isoformat()]
+ unicode(self.latest_file_info.timestamp.isoformat())]
@deprecated('FilePage.get_file_history()')
def getFileVersionHistory(self):
--
To view, visit https://gerrit.wikimedia.org/r/224437
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I92ef76a9988b6cccb42fffdd52a224850337ec49
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: 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: [FIX] undelete: Get correct token
......................................................................
[FIX] undelete: Get correct token
The original implementation cdc2e9f4 used `undelete` token and added it as an
old token type. So on new implementations using the CSRF token this worked as
it mapped the token to CSRF. But old versions of MediaWiki which don't use the
CSRF token yet it'll fail because that token never existed.
The change in d4e6e60c broke then this also on newer versions as it only mapped
old token names to the CSRF token if they were actually old token name. And
that is not the case for `undelete` so it wasn't mapped to CSRF.
With 730bad3f the tokens for `delete` and `undelete` are the same and so it can
just use the `delete` token which will be mapped to CSRF on recent versions.
Bug: T105635
Change-Id: I9419aac0bc590fd3a3ed484012608f25dcf01cea
---
M pywikibot/site.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index afed231..fc00d47 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4771,7 +4771,7 @@
@type reason: basestring
"""
- token = self.tokens['undelete']
+ token = self.tokens['delete']
self.lock_page(page)
req = self._simple_request(action='undelete',
--
To view, visit https://gerrit.wikimedia.org/r/224391
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9419aac0bc590fd3a3ed484012608f25dcf01cea
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] page: Return timestamp string
......................................................................
[FIX] page: Return timestamp string
Several methods (BasePage.getCreator(), BasePage.getLatestEditors(),
FilePage.getLatestUploader() and FilePage.getFirstUploader()) use the direct
result from the API and not a Timestamp instance.
The first two methods were added in f562b94d, the second in d298facc and the
last in bc4df36a. Both FilePage related methods were added with or after the
FileInfo class was added and the BasePage methods use the Revision class. Both
classes, FileInfo and Revision used Timestamp instances at that point already.
This can technically break parts although all methods have been already
deprecated when they were added to the library. So scripts should have changed
to the current replacements if they were fixed.
Change-Id: I82c2984ec736529acbe3aa8ac9dde6aadb91fcdd
---
M pywikibot/page.py
M tests/file_tests.py
M tests/page_tests.py
3 files changed, 45 insertions(+), 7 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
XZise: Looks good to me, but someone else must approve
Xqt: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index adac029..7ea7337 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1578,7 +1578,7 @@
@rtype: tuple(username, Timestamp)
"""
result = self.oldest_revision
- return result.user, result.timestamp
+ return result.user, result.timestamp.isoformat()
@deprecated('contributors() or revisions()')
@deprecated_args(limit="total")
@@ -1590,7 +1590,7 @@
@param total: iterate no more than this number of revisions in total
@rtype: list of dict, each dict containing the username and Timestamp
"""
- return [{'user': rev.user, 'timestamp': rev.timestamp}
+ return [{'user': rev.user, 'timestamp': rev.timestamp.isoformat()}
for rev in self.revisions(total=total)]
@deprecate_arg("throttle", None)
@@ -2229,7 +2229,8 @@
For compatibility with compat only.
"""
- return [self.oldest_file_info.user, self.oldest_file_info.timestamp]
+ return [self.oldest_file_info.user,
+ self.oldest_file_info.timestamp.isoformat()]
@deprecated("FilePage.latest_file_info.user")
def getLatestUploader(self):
@@ -2238,7 +2239,8 @@
For compatibility with compat only.
"""
- return [self.latest_file_info.user, self.latest_file_info.timestamp]
+ return [self.latest_file_info.user,
+ self.latest_file_info.timestamp.isoformat()]
@deprecated('FilePage.get_file_history()')
def getFileVersionHistory(self):
diff --git a/tests/file_tests.py b/tests/file_tests.py
index 625df91..7cb538c 100644
--- a/tests/file_tests.py
+++ b/tests/file_tests.py
@@ -11,7 +11,12 @@
import pywikibot
-from tests.aspects import unittest, TestCase
+from pywikibot.tools import PY2
+
+from tests.aspects import unittest, TestCase, DeprecationTestCase
+
+if not PY2:
+ unicode = str
class TestShareFiles(TestCase):
@@ -150,6 +155,34 @@
image = image.latest_file_info
+class TestDeprecatedFilePage(DeprecationTestCase):
+
+ """Test deprecated parts of FilePage."""
+
+ family = 'commons'
+ code = 'commons'
+
+ cached = True
+
+ def test_getFirstUploader(self):
+ """Test getFirstUploader."""
+ page = pywikibot.FilePage(self.site, 'File:Albert Einstein.jpg')
+ first = page.getFirstUploader()
+ self.assertOneDeprecation()
+ self.assertEqual(first, ['Herbizid', '2011-03-18T10:04:48Z'])
+ self.assertIsInstance(first[0], unicode)
+ self.assertIsInstance(first[1], unicode)
+
+ def test_getLatestUploader(self):
+ """Test getLatestUploader."""
+ page = pywikibot.FilePage(self.site, 'File:Albert Einstein.jpg')
+ latest = page.getLatestUploader()
+ self.assertOneDeprecation()
+ self.assertEqual(len(latest), 2)
+ self.assertIsInstance(latest[0], unicode)
+ self.assertIsInstance(latest[1], unicode)
+
+
if __name__ == '__main__':
try:
unittest.main()
diff --git a/tests/page_tests.py b/tests/page_tests.py
index 6504b45..ae983a6 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -516,9 +516,12 @@
def test_creator(self):
"""Test getCreator."""
mainpage = self.get_mainpage()
- self.assertEqual(mainpage.getCreator(),
+ creator = mainpage.getCreator()
+ self.assertEqual(creator,
(mainpage.oldest_revision.user,
- mainpage.oldest_revision.timestamp))
+ mainpage.oldest_revision.timestamp.isoformat()))
+ self.assertIsInstance(creator[0], unicode)
+ self.assertIsInstance(creator[1], unicode)
self.assertDeprecation()
self._reset_messages()
--
To view, visit https://gerrit.wikimedia.org/r/224310
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I82c2984ec736529acbe3aa8ac9dde6aadb91fcdd
Gerrit-PatchSet: 2
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: Steinsplitter <steinsplitter(a)wikipedia.de>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2527
Status: Fixed
Duration: 23 minutes and 36 seconds
Commit: e089562 (master)
Author: Fabian Neundorf
Message: [FIX] checkimages: Expect Timestamp instance
The checkimages script uses since d298facc the FileInfo class returned by
FilePage instances. And these classes always return Timestamp instances so the
script needs to be adjusted to that.
Bug: T105188
Change-Id: I2b6257af05a2ecc620d718872a0b6d3f0a7f64e4
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/27ef088dbc79...e089562a…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/70636952
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications