jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Ignore warnings on upload ......................................................................
[FIX] Ignore warnings on upload
Although MediaWiki ignored the warnings it still returned them which caused APISite.upload() to claim no success.
Bug: 58907 Change-Id: I6b0f538879d0c249e5baa95eccd2d1c6fefb6483 --- M pywikibot/site.py M scripts/upload.py 2 files 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 fe0eb02..f159130 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -4306,8 +4306,7 @@ "User '%s' does not have upload rights on site %s." % (self.user(), self)) # check for required parameters - if (source_filename and source_url)\ - or (source_filename is None and source_url is None): + if bool(source_filename) == bool(source_url): raise ValueError("APISite.upload: must provide either " "source_filename or source_url, not both.") if comment is None: @@ -4353,7 +4352,7 @@ if error.code == u'uploaddisabled': self._uploaddisabled = True raise error - if 'warnings' in data: + if 'warnings' in data and not ignore_warnings: result = data break file_key = data['filekey'] @@ -4400,7 +4399,8 @@ result = result["upload"] pywikibot.debug(result, _logger)
- if "warnings" in result: + if "warnings" in result and not ignore_warnings: + #TODO: Handle multiple warnings at the same time warning = list(result["warnings"].keys())[0] message = result["warnings"][warning] raise pywikibot.UploadWarning(warning, upload_warnings[warning] diff --git a/scripts/upload.py b/scripts/upload.py index 1418fa2..aab2f62 100755 --- a/scripts/upload.py +++ b/scripts/upload.py @@ -273,7 +273,7 @@ answer = pywikibot.inputChoice(u"Do you want to ignore?", ['Yes', 'No'], ['y', 'N'], 'N') if answer == "y": - self.ignoreWarning = 1 + self.ignoreWarning = True self.keepFilename = True return self.upload_image(debug) else:
pywikibot-commits@lists.wikimedia.org