WikiRobots

Overview
Repetitive tasks can be automated using robots or bots, i.e. software programs operating on the wiki by themselves.

The natural and most commonly used robots for wiki sites are provided by MediaWiki, under the package name Pywikibot. See Manual:Pywikibot for the full information.

In a nutshell, Pywikibot is a collection of Python scripts able to use the native wiki API to act on wiki sites. To see the API list for the FreeCAD wiki, visit http://www.freecadweb.org/wiki/api.php

In order to use Pywikibot, you need to:


 * 1) install the Pywikibot package
 * 2) configure Pywikibot to work on the FreeCAD Wiki
 * 3) launch the scripts you need for the task at hand

There is a wealth of information on how to install, configure and use Pywikibot. However, please be aware that this information, although useful, can be misleading, since it mixes instructions related to two different Pywikibot codebases, and different versions of the Pywikibot scripts collection.

In the following, you will find the basic instructions to set up and use Pywikibot on the FreeCAD wiki. This will allow you to perform the most common tasks. For advanced usage, refer to the Manual:Pywikibot, and to the Python source code.

Installation
Go to http://tools.wmflabs.org/pywikibot/ and download (the project is also under github, gerrit, etc. but this is a simple way to get a full self-contained package).

Unzip the content in your preferred directory.

Unless you want to install the libraries into your Python libs, you are done (if you still want to install them, check the file in the base directory).

Pywikibot works with Python 2.6 and 2.7 with no issues. Python 3 has been not tested so far with FreeCAD wiki.

Configuration
You must save the following Python code as a file with the name in the base directory where you unzipped  (to be clear, in the same directory where you already find a file called ).

In the above code:


 * replace <> with your Wiki user name
 * replace cp437 with your console_encoding. To find out what is your console encoding, for Windows and Linux, launch the Python interpreter, enter followed by . Python will write your  on the screen.

Then you must save the following Python code as a file with the name under the sub-directory  (together with the other  files).

Usage
You are now all set to launch the Pywikibot scripts. The scripts themselves are contained in the subdirectory, from which you can know the names.

To launch the scripts, open a shell and move to the base directory (the installation one, NOT the subdirectory), and write

where of course you replace < > with the name of the script you are interested in, and < > with the parameter(s) required for the given script.

To have a description of the usage and parameters of any script, simply use the -help parameter. For instance, to have a description of the script (one of the most useful), type

There is another very useful parameter, valid for all the scripts, called -simulate, that allows you to test commands without harming the Wiki. Use it, before going 'live'.

Examples
This command will log into the wiki

This command will print a list of all the pages containing a link to SourceForge

This command will replace all the links to the old SourceForge Forum with a link to the new freecadweb.org-hosted Forum

This command will print a list of all the pages containing the word 'PartDesign', starting with the page titled "2d Drafting Module" and going on alphabetically

This command will replace all the secure links to the old SourceForge Forum with a link to the new freecadweb.org-hosted Forum in the translated pages

FreeCAD Wiki Related Commands
Count all pages that a specific wiki templates is used in

List all pages that a specific wiki templates is used in

Replace a string in all the pages listed in the Arch category (a/k/a )