Free Software Directory:Pywikibot

From Free Software Directory
Jump to: navigation, search

Free Software Directory:Participate/Using pywikibot should be merged to this page.


  • Add this to LocalSettings.php
# Allow batch uploading for pywikibot
$wgGrantPermissions['editpage']['approverevisions'] = true; # Required by the MediaWiki Extension "Approved Revs" to create new pages
$wgGrantPermissions['editprotected']['editarticles'] = true;
$wgFileExtensions[] = 'wiki';

Generate a bot account for your user

The bot will be associated with the user name that are logged in.

Background to using the bot

The method of using BotPasswords improves the security overall. However bot's are required due to a CASAuth issue:

See also the CASAuth issue on this page.



# The scripts/ requires scripts/i18n/ (eg scripts/i18n/pagefromfile/) that is pulled with the --recursive option (or "cd pywikibot-core && git submodule update --init" after git clone)
git clone --recursive "$pywikibot_dir"
cd "$pywikibot_dir"
python "$site" "$family"
python generate_user_files
# Select family of sites we are working on, just enter the number or name (default: wikipedia): freesoftwaredirectory
# The only known language: en
# The language code of the site we're working on (default: en): 
# Username on en:freesoftwaredirectory: WikiSysop
# Do you want to add any other projects? ([y]es, [N]o): n
# Do you want to add a BotPassword for WikiSysop? ([y]es, [N]o, [q]uit): y
# See to
# know how to get codes.Please note that plain text in /home/root
# /pywikibot-core/ and anyone with read access to that
# directory will be able read the file.
# BotPassword's "bot name" for WikiSysop: wikibot
# BotPassword's "password" for "WikiSysop" (no characters will be shown): 
# '/home/root/pywikibot-core/' written.

Test pywikibot on MediaWiki

python upload -always -ignorewarn ~/heckert_gnu.transp.small.png "Some description"

Estimate time for batch uploading

script_generated=$(date +"%Y-%m-%d %H:%M:%S.%N"); # .wiki files with identical content since the last revision will be ignored ("No changes were needed on [[YOURTITLE]]")

for (( i=0; i<10; i++ )); do
  echo "$script_generated" >;
  python pagefromfile -summary:"The edit summary" -title:"Test$i" -file:"" -textonly -force -pt:0
echo "$(($duration / 10)) seconds per entry in average."
rm -f



This issue doesn't have to be fixed since there's a work around, but it would be great if it were fixed to give us more options.


Pywikibot [1] is a MediaWiki bot library which we are attemting to utilize to perform batch uploads. However, because of CASAuth, we are unable [2] to perform main account CAS-based login, and have to resort to using BotPasswords. However, to upload, permissions to alter "File" namespace is needed, but it is restricted to the 'editarticles' permission [4], and there is no grant [5] that gives the permission to any BotPasswords-based login. Please add 'editarticles' to the 'Edit protected pages' set [5], or any other set if you deem appropriate, to allow batch uploading.


//, zhuyifei1999_ in #pywikibot at,



pywikibot can be used with OAuth - However, the OAuth extension is currently not installed -

Further reading

Read,_pagefromfile.py_and_Nokogiri for more information

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the page “GNU Free Documentation License”.

The copyright and license notices on this page only apply to the text on this page. Any software or copyright-licenses or other similar notices described in this text has its own copyright notice and license, which can usually be found in the distribution or license text itself.