Last modified: 2014-10-07 13:27:52 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T71090, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 69090 - upload.py attempts uploads on wikis that don't allow uploads
upload.py attempts uploads on wikis that don't allow uploads
Status: RESOLVED FIXED
Product: Pywikibot
Classification: Unclassified
Other scripts (Other open bugs)
core-(2.0)
All All
: Low enhancement
: ---
Assigned To: Pywikipedia bugs
:
Depends on: 70075
Blocks:
  Show dependency treegraph
 
Reported: 2014-08-04 04:00 UTC by John Mark Vandenberg
Modified: 2014-10-07 13:27 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description John Mark Vandenberg 2014-08-04 04:00:53 UTC
Uploads are disabled on Wikidata: https://www.wikidata.org/wiki/Special:Upload

upload.py happily allows the user to attempt to upload, but then reports an APIError.  If pywikibot cant detect whether uploads are enabled before upload, it should detect this APIError and provide a nice response for the user.

$ python pwb.py -family:wikidata -lang:wikidata scripts/upload.py
No input filename given
File or URL where image is now: blahblah.png
The filename on the target wiki will default to: blahblah.png
Enter a better name, or press enter to accept: 
The suggested description is:

Do you want to change this description? ([y]es, [N]o) y
Uploading file to wikidata:wikidata via API....
Reading file blahblah.png
ERROR: Upload error: 
Traceback (most recent call last):
  File "scripts/upload.py", line 216, in upload_image
    ignore_warnings=self.ignoreWarning)
  File ".../pywikibot/site.py", line 3432, in upload
    result = req.submit()
  File ".../pywikibot/data/api.py", line 418, in submit
    raise APIError(code, info, **result["error"])
APIError: uploaddisabled: Uploads are not enabled. Make sure $wgEnableUploads is set to true in LocalSettings.php and the PHP ini setting file_uploads is true
Comment 1 Mpaa 2014-08-27 08:17:57 UTC
See https://gerrit.wikimedia.org/r/156465
Comment 2 John Mark Vandenberg 2014-09-11 08:09:03 UTC
It is a bit better now, as there is no traceback, but the check and error needs to occur before asking the user a lot of questions.

$ python pwb.py upload -family:wikidata -lang:test
No input filename given
File or URL where image is now: https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png
The filename on the target wiki will default to: PNG_transparency_demonstration_1.png
Enter a better name, or press enter to accept: 
The suggested description is:

It is not possible to upload a file without a summary/description.
Do you want to change this description? ([Y]es, [n]o, [q]uit) y
Uploading file to wikidata:test via API....
Reading file https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png
WARNING: API warning (tokens): action=tokens has been deprecated. Please use action=query&meta=tokens instead.
ERROR: Upload error: Local file uploads are disabled on wikidata:test.
Comment 3 Fabian 2014-10-07 09:17:07 UTC
We might need to be avare of bug 33731. John suggested to download the HTML Code of Special:Upload and check if the upload edit box is present.
Comment 4 Mpaa 2014-10-07 11:36:41 UTC
I submitted this patch. Do not why it was not logged here:
https://gerrit.wikimedia.org/r/#/c/159836/
Comment 5 Fabian 2014-10-07 11:39:25 UTC
Oh nevermind. Bug 33731 is emitting not 'uploaddisabled' so it's not related to this.
Comment 6 Andre Klapper 2014-10-07 13:27:52 UTC
(In reply to Mpaa from comment #4)
> I submitted this patch. Do not why it was not logged here:
> https://gerrit.wikimedia.org/r/#/c/159836/

See http://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines for the required format.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links