Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #4097
Status: Passed
Duration: 2 hours, 11 minutes, and 5 seconds
Commit: 737b037 (master)
Author: xqt
Message: [IMPR] Make pywikibot.Error more precise
- OptionHandler.getOption raises pywikibot.Error if the given option is not
given in availableOptions. OptionHandler is not used by BaseBot class only
but also by some generator classes. Make the error message more precise.
Bug: T166982
Change-Id: I011c5d928dba19c7c8f355be19864c56532e52e2
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/95fa6def49df...737b0371…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/239331032?utm_source=…
--
You can configure recipients for build notifications in your .travis.yml file. See https://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/357120 )
Change subject: [IMPR] Make pywikibot.Error more precise
......................................................................
[IMPR] Make pywikibot.Error more precise
- OptionHandler.getOption raises pywikibot.Error if the given option is not
given in availableOptions. OptionHandler is not used by BaseBot class only
but also by some generator classes. Make the error message more precise.
Bug: T166982
Change-Id: I011c5d928dba19c7c8f355be19864c56532e52e2
---
M pywikibot/bot.py
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index f78be24..191aaeb 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1180,11 +1180,13 @@
Get the current value of an option.
@param option: key defined in OptionHandler.availableOptions
+ @raise Error: No valid option is given with option parameter
"""
try:
return self.options.get(option, self.availableOptions[option])
except KeyError:
- raise pywikibot.Error(u'%s is not a valid bot option.' % option)
+ raise pywikibot.Error("'{0}' is not a valid option for {1}."
+ .format(option, self.__class__.__name__))
class BaseBot(OptionHandler):
--
To view, visit https://gerrit.wikimedia.org/r/357120
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I011c5d928dba19c7c8f355be19864c56532e52e2
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/356987 )
Change subject: FilePage.download(): add revision parameter to download arbitrary revision
......................................................................
FilePage.download(): add revision parameter to download arbitrary revision
The parameter will default to the latest revision when unprovided,
so that this method remain backwards-compatiable. The revision
(instance of FileInfo) will provide the url and sha1 for the download
and verification process.
Bug: T166939
Change-Id: I25842ae4276fbb45ba69a31d66b67401723e3ee5
---
M pywikibot/page.py
1 file changed, 14 insertions(+), 4 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 78c2f79..ddd24d9 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2634,7 +2634,7 @@
return self.site.upload(self, source_filename=filename, source_url=url,
**kwargs)
- def download(self, filename=None, chunk_size=100 * 1024):
+ def download(self, filename=None, chunk_size=100 * 1024, revision=None):
"""
Download to filename file of FilePage.
@@ -2642,7 +2642,14 @@
None: self.title(as_filename=True, withNamespace=False)
will be used
str: provided filename will be used.
- @type None or str
+ @type filename: None or str
+ @param chunk_size: the size of each chunk to be received and
+ written to file.
+ @type chunk_size: int
+ @param revision: file revision to download:
+ None: self.latest_file_info will be used
+ FileInfo: provided revision will be used.
+ @type revision: None or FileInfo
@return: True if download is successful, False otherwise.
@raise: IOError if filename cannot be written for any reason.
"""
@@ -2651,7 +2658,10 @@
filename = os.path.expanduser(filename)
- req = http.fetch(self.latest_file_info.url, stream=True)
+ if revision is None:
+ revision = self.latest_file_info
+
+ req = http.fetch(revision.url, stream=True)
if req.status == 200:
try:
with open(filename, 'wb') as f:
@@ -2661,7 +2671,7 @@
raise e
sha1 = compute_file_hash(filename)
- return sha1 == self.latest_file_info.sha1
+ return sha1 == revision.sha1
else:
pywikibot.warning('Unsuccesfull request (%s): %s' % (req.status, req.uri))
return False
--
To view, visit https://gerrit.wikimedia.org/r/356987
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I25842ae4276fbb45ba69a31d66b67401723e3ee5
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #4093
Status: Broken
Duration: 2 hours, 1 minute, and 26 seconds
Commit: 5159e45 (master)
Author: dalba
Message: MWSite.__init__: Re-raise the RequestException of _parse_post_117
If there is any kind of RequestException in _parse_post_117, it means
that the `private_wiki` attribute has not had a chance to be set and
will definitly cause AttributeError later in the code.
Raising the RequestException is more clear and will allow the related
test to be skipped.
Bug: T160355
Change-Id: I75eb7c35a1e030a309bdf271a7ddc8ac69052ab9
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/aab4688cda91...5159e45c…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/238135517?utm_source=…
--
You can configure recipients for build notifications in your .travis.yml file. See https://docs.travis-ci.com/user/notifications