Manual talk:Pywikibot/upload.py

From MediaWiki.org
Jump to navigation Jump to search
The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

403 Forbidden error[edit]

Hi,

When I try to upload an image using this script I get a 403 Forbidden page back. Manually uploading using the bot user account works and editing an article using the editarticly.py script works to. Anybody knows why upload.py does not work? I'm running Mediawiki 1.6.3 and am using the newest upload.py available. thnx --GrandiJoos 18:16, 1 May 2006 (UTC)

An Idea[edit]

GrandiJoos - You should be able to get information about why the page is forbidden by checking the server logs. These should be available through your web hosting service, and are automatically kept by the web server program (like Apache). In general there are two reasons for a 403 error: wrong permissions on the file, or wrong un/pw. If you are able to access your wiki when you log in, then you are probably requesting a nonexistent file. The server logs should record every file that was requested by a client that it couldn't find.

Also, make sure you check the path specified by grandijooswiki_family.py (or whatever_family.py) is accurate. This is the default:

   def path(self, code):
       return '/wiki/index.php'

And if your wiki is in the root folder of your server, you might need this:

   def path(self, code):
       return '/index.php'

Hope that helps

Ioneil 22:05, 20 May 2006 (UTC)

'utf8' Can't Decode Byte[edit]

I am able to log in without any problems, but when I try to upload any image (using URL or local file) to the server, I get the following error message:

Traceback (most recent call last):
 File "C:\Documents and Settings\Jim\My Documents\Downloads\Applications\Python WikiBot\pywikipedia\upload.py", line 251, in ?
   main(sys.argv[1:])
 File "C:\Documents and Settings\Jim\My Documents\Downloads\Applications\Python WikiBot\pywikipedia\upload.py", line 247, in main
   bot.run()
 File "C:\Documents and Settings\Jim\My Documents\Downloads\Applications\Python WikiBot\pywikipedia\upload.py", line 229, in run
   return self.upload_image()
 File "C:\Documents and Settings\Jim\My Documents\Downloads\Applications\Python WikiBot\pywikipedia\upload.py", line 201, in upload_image
   returned_html = returned_html.decode(self.targetSite.encoding())
 File "C:\Python24\lib\encodings\utf_8.py", line 16, in decode
   return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa9 in position 342: unexpected code byte

I get the same error no matter what image file I use. I am running python 2.4 on Windows XP, and my user-config.py setting are:

mylang = 'en'
family = 'uwpn'
usernames['uwpn']['en'] = 'WikiBot'
console_encoding = 'utf-8'

Any advice?

Ioneil 21:58, 20 May 2006 (UTC)

Upload multiple files?[edit]

Can I upload multiple files at once with this .py file? Odessaukrain 04:37, 8 January 2007 (UTC)

I hacked together Uploadmultiple.py which did the job for me. It's sloppy, but seems to work well enough. -Jonathan Kovaciny 21:57, 8 June 2007 (UTC)

Block Warnings[edit]

Is there any way to blog all warnings (like chaching name, file bigger them 150k, overwriting file etc.)?

Problem[edit]

I repeatedly get the following error message. I am able to upload images using Commons:Special:Upload. I am able to upload text using pagefromfile.py. A similar problem was reported in April.[1] I would welcome suggestions.

filename: Acer_glabrum_2673f.JPG token: 7d2b0dab6c2aeea919ac20492dd2b685+\


Requesting API query from commons:commons <urlopen error [Errno 35] Resource temporarily unavailable> WARNING: Could not open 'http://commons.wikimedia.org/w/api.php'. Maybe the server or your connection is down. Retrying in 1 minutes...

Walter Siegmund (talk) 00:24, 16 May 2010 (UTC)

If you're having this problem on Mac OS X, it's because of a weird problem introduced by the socket implementation for OS X see here. You can easily fix it for pywikipedia by adding socket_timeout = None to your user-config.py. If you're not on OS X, I'm not sure what's causing the problem for you.

Error creating thumbnail (solved)[edit]

The image shows that it uploads fine in pywikipediabot, but when looking at the image, it is gray with this message:

Error creating thumbnail: /usr/bin/convert: Unrecognized option (-thumbnail).

Adamtheclown 10:27, 19 November 2010 (UTC)

solution found here.[2] Adamtheclown 10:35, 19 November 2010 (UTC)

Uploadmultiple.py[edit]

The uploadmultiple.py bot is a dead project? Here the content page. Sorry for my little english! --79.35.55.159 22:09, 7 November 2012 (UTC)

-summary does not work (done)[edit]

User:Framawiki it seems that summary is not working on toolforge:

tools.svgworkaroundbot@tools-bastion-03:~/SVGWorkaroundBot/cleanupSVG-master$ python /data/project/shared/pywikipedia/core/scripts/upload.py Oxygen480-status-weather-mist.svg -keep -ignorewarn -summary MySummary
The suggested description is:
MySummary
Do you want to change this description? ([y]es, [N]o, [q]uit): n
Uploading file to commons:commons...
ERROR: Upload error:
Traceback (most recent call last):
  File "/data/project/shared/pywikibot/core/pywikibot/specialbots.py", line 430, in upload_file
    comment=self.summary)
  File "/data/project/shared/pywikibot/core/pywikibot/page.py", line 2682, in upload
    **kwargs)
  File "/data/project/shared/pywikibot/core/pywikibot/tools/__init__.py", line 1738, in wrapper
    return obj(*__args, **__kw)
  File "/data/project/shared/pywikibot/core/pywikibot/site.py", line 6194, in upload
    raise ValueError('APISite.upload: cannot upload file without '
ValueError: APISite.upload: cannot upload file without a summary/description.
1 pages read
0 pages written
Script terminated successfully.
tools.svgworkaroundbot@tools-bastion-03:~/SVGWorkaroundBot/cleanupSVG-master$ python /data/project/shared/pywikipedia/core/scripts/upload.py Oxygen480-status-weather-mist.svg -keep -ignorewarn -noverify -summary MySummary
The suggested description is:
MySummary
Uploading file to commons:commons...
ERROR: Upload error:
Traceback (most recent call last):
  File "/data/project/shared/pywikibot/core/pywikibot/specialbots.py", line 430, in upload_file
    comment=self.summary)
  File "/data/project/shared/pywikibot/core/pywikibot/page.py", line 2682, in upload
    **kwargs)
  File "/data/project/shared/pywikibot/core/pywikibot/tools/__init__.py", line 1738, in wrapper
    return obj(*__args, **__kw)
  File "/data/project/shared/pywikibot/core/pywikibot/site.py", line 6194, in upload
    raise ValueError('APISite.upload: cannot upload file without '
ValueError: APISite.upload: cannot upload file without a summary/description.
1 pages read
0 pages written
Script terminated successfully.

I used -descfile and now it works JoKalliauer (talk) 21:52, 4 March 2019 (UTC)

@JoKalliauer: Hello, you set no summary there. You should use -summary:"MySummary". What you've done you set uploaded file description, not summary. --Dvorapa (talk) 22:26, 23 March 2019 (UTC)
@Dvorapa: I thougth description is the Page and the Summary is whats written in the #filehistory for each versions. So in https://commons.wikimedia.org/w/index.php?title=File:Oxygen480-devices-tools-media-optical-format.svg&diff=prev&oldid=341549170#filehistory "WorkaroundBotsvg2validsvg.sh" is the description not the summary? And the Summary is "SVGWorkaroundBot uploaded a new version of File:Oxygen480-devices-tools-media-optical-format.svg" ? JoKalliauer (talk) 19:53, 24 March 2019 (UTC)
Summary is what is written in the page history (https://commons.wikimedia.org/w/index.php?title=File:Oxygen480-devices-tools-media-optical-format.svg&action=history) and your should fill it using -summary:"some summary". Description is what is written in the #filehistory and you should fill it using "some description". Your issue was you used -summary without any value. You should use either:
python upload.py Oxygen480-status-weather-mist.svg -keep -ignorewarn -noverify -summary:MySummary MyDescription
or python upload.py Oxygen480-status-weather-mist.svg -keep -ignorewarn -noverify MyDescription to use default summary. --Dvorapa (talk) 20:34, 24 March 2019 (UTC)
Thanks for your answer Yes Done JoKalliauer (talk) 07:19, 25 March 2019 (UTC)