Manual:Pywikibot/Development

How to report a bug
When you report a bug please try to include:


 * PyWikipediaBot version in use. It's recommended to test if the bug is still present in latest SVN revision available.
 * Python version (python -V) and operating system you use (e.g. Windows, Linux, MacOS...)
 * For above purpose, version.py will be useful.
 * A nice summary
 * Full description of the problem/report
 * How to reproduce bug full information (script, command line, family, and language used)
 * The console output provided by the script (included the Python traceback if you are reporting a crash)

To submit a new bug visit the bug tracker provided by SourceForge.

Development
If you have a function you want to have a bot for that is not yet provided by one of the bots, you can ask one of the programmers to write it for you. Or even better, you can try to work on the bots yourself. Python is a nice language, and not hard to learn. We will welcome you.

Commit access
To request commit access, first email the mailing list and explain what you'd like to work on. Once you've gotten a little community consensus that you should get access, submit a formal commit access request and mention that you'd like pywikipediabot commit access, and point to the mailing list thread where you got an OK from the pywikipediabot community. Example.

Tips
Here and in wikipedia.py, there are some very basic tips for getting started writing your own bot:
 * be sure you've set up your user-config.py file (see above)
 * To gain access to the pywikipedia framework, use:
 * to retrieve a page, use the following, where pageName is, e.g., "Wikipedia:Bots" or "India":
 * to update a page, use:
 * look at some of the pywikipedia files for other ideas -- basic.py is relatively easy to read even if you're new to pywikipedia.
 * you can find all available Page methods in the wikipedia.py file.
 * basic.py gives you a setup that can be used for many different bots, all you have to do is define the string editing on the page text.
 * To iterate over a set of pages, see pagegenerators.py for some objects that return a set of pages. An example use of the CategoryPageGenerator that does something for each page in the Category:Living people category:

Contributing changes
If you changed the bot and want to send a patch to the maintainer,
 * 1) Update to the current version (it will merge your changes with the improvements already committed to the SVN Repository),
 * 2) Resolve any conflicts caused by the update (grep for "=====" ;-) and
 * 3) Type:
 * $ svn diff > svn.diff

Review the diff to ensure it only includes the changes you want to contribute. The lines at the beginning starting with "?" should be removed.

If you are in direct contact with a Pywikipediabot developer, you can send the file svn.diff to him, but preferably attach the patch to a ticket in the Pywikipedia bug tracking system.

Multiple accounts
It is a common need to run python wikipedia bot under different accounts (main and/or multiple bot accounts). It can be done in two ways.

Separate pywikipedia distributions
One can install completely separate instances of pywikipedia in different directories (1 for each account) and have diferent  files in each of them. However, when updating the installation via SVN, one needs to run  on each folder separately. Also, every installation takes some disk space, which might be a problem on accounts with limited quota.

One pywikipedia distribution with symbolic links
Let's assume user  has a current SVN working copy of pywikipedia in. For each of the accounts, he creates a separate directory:

foo@bar:~$ mkdir foobot foo@bar:~$ cd foobot

Pywikipedia needs then some symlinks to the main code tree created in the working directory:

foo@bar:~/foobot$ ln -s ~/pywikipedia/families foo@bar:~/foobot$ ln -s ~/pywikipedia/userinterfaces

Then,  for this account must be created as described in Configuration section above.

Finally, the bot must be logged in the usual way:

foo@bar:~/foobot$ python ~/pywikipedia/login.py

The working directory is ready. The scripts will however require a slight modification to run (the path to the pywikipedia tree must be added to Python's path).

import sys, os sys.path.append(os.environ['HOME'] + '/pywikipedia') import wikipedia

That's all. Updating to the newest version of pywikipedia on all accounts at once is now a matter of running  only in the   directory.

On Windows 2000+ with NTFS
A similar set-up can be created on Windows systems running Windows 2000 or later that use NTFS as their filesystem. This can be achieved by using the  tool (available from Microsoft's website, part of the sysinternals suite).

As above, create your new directory, but to create the symlinks, create  and   as directories inside of that. (NB: The cmd.exe  appears not to work properly in all the time, so using the Right-click->New menu or File->New menu is suggested.)

C:\...> junction families C:\pywikipedia\families C:\...> junction userinterfaces C:\pywikipedia\userinterfaces

The rest of the method is the same as above. Symlink/junctions should be deleted using the  program, as you may accidentally lose data in the original directory (see ).

Bot & Proxy
There is probably (not tested!) draft workaround described here.