Manual:Pywikibot/Installation/Toolforge/fr

Initialisation de Wikimedia Labs/Serveur Tool Labs
Afin d'installer votre robot sur les serveurs de Wikimedia et l'exécuter depuis eux, assurez-vous d'abord d'être familiarisé avec l'environnement Wikimedia Labs/Tool Labs.

Pour l'étape suivante, vous devez demander plusieurs comptes (pour labs, pour le projet tools, pour votre propre outil), et fournir une clé ssh etc... Comment faire cela et quelle est la procédure, tout cela est décrit en détails dans Configurer pywikibot dans Labs.

L'archivage des sources Pywikibot a été déplacé vers Git (depuis SVN), veuillez donc vous référer d'abord à Manual:Pywikipediabot/Gerrit.

The bots projects here has become obsolete, instead we use tools now, in order to do so follow Tools/Help to get an account. Then create your tool (service group).

If you used the toolserver in the past and know how everything used to work there, confer migrating from toolserver for more info.

Maintenant vous êtes prêt à commencer. Connectez-vous au projet Labs tools :

$ ssh USERNAME@login.tools.wmflabs.org

passez sur le compte de l'outil avec

maintainer@tools-login:~$ become toolname local-toolname@tools-login:~$

Now install/clone the pywikibot code to your tool account as described below.

Installer le code du robot
Suivez les instructions d'une manière similaire à ce qui est décrit dans ce courriel :

$ git clone --recursive https://gerrit.wikimedia.org/r/pywikibot/core.git pywikibot-core $ cd pywikibot-core

Now you have to setup pywikibot. Choose any one of the following processes to configure your system:
 * Execute
 * Run your favorite bot script (e.g. ) since you are doing this in a fresh clone, it will trigger a bunch of questions on how you want to configure your local copy, answer them carefully in order to proceed.
 * If you already have a config file(s) from a previous version, you can copy those existing files into the right places (e.g. pywikibot-compat/).

Further things you might have to do (depending on what bot scripts you want to run) is to setup all externals properly - which still has to be done manually in core

$ cd externals $ cat README

et suivez-y les instructions.

You will also have to enter the password for your bot eventually.

Now you have finished the configuration of core and can continue setting up the jobs to execute.

Setup the webspace
By default, the directory listing on http://tools.wmflabs.org/TOOLNAME is disabled. If you want to allow it for all users, login to your tool account (as already described) and

$ cd ~/public_html $ echo Options +Indexes >> .htaccess

If you run a bot with the  option, you will find the log files within the   directory. If you want to allow users to access it from the web, do

$ cd ~/public_html $ mkdir logs $ cd logs $ ln -s ~/pywikibot-core/logs cor

If you want a specific file type to be handled differently by your browser, e.g.  files like text files, use (confer this)

$ echo AddType text/plain .log >> .htaccess

and (don't forget to) clear your browsers cache afterwards.

Next you might want to consider you  directory

$ cd ~/cgi-bin

follow the hints given at wikitech:Nova Resource:Tools/Help exactly, e.g. even the two commands

$ /usr/bin/python     # valid $ /usr/bin/env python # in-vali

work and do the same in shell, only the first one is valid and works here, the second is invalid! Another point to mention is that PHP scripts go into public_html, not cgi-bin. Python scripts on the other hand can be placed in public_html or cgi-bin as you wish. It is recommended to use  for documents and keep it listable, whereas   should be used for CGI scripts and be protected (not listable).

Initialiser la soumission d'une tâche
In order to setup the submission of the jobs you want to execute and use the grid engine you should first consider wikitech:Nova Resource:Tools/Help and if you are familiar with the Toolserver and its architecture consult Migrating from toolserver also.

In general labs uses SGE and its commands like  et al, this is explained in this document which you should use in order to get an idea which command and what parameters you want to use.

An infinitely running job (e.g. irc-bot) like this ( entry from TS submit host):

devient

ou plus court

the first expression is good for debugging. Memory values smaller than 256MB seam not to work here, since that is the minimum. If you experience problems with your jobs, like e.g. Fatal Python error: Couldn't create autoTLSkey mapping you can try increasing the memory value - which is also needed here, because this script uses a second thread for timing and this thread needs memory too. Therefore use finally

Now in order to create a crontab follow Scheduling jobs at regular intervals with cron and setup for crontab file like: $ crontab -e and enter

Configuration supplémentaire
Furthermore additional tools to support you and your bot at work are available:
 * wikitech:Nova Resource:Tools/Help, basically out-of-the-box but just for a short time period
 * wikitech:Nova Resource:Tools/Help
 * Gerrit/New repositories
 * Git/New repositories/Requests

Mise à jour automatique de Git sur Wikimedia Labs
For automatic updating you can make update bash file and put it in root and fill it with these commands, For WMF labs (in your service group):

and then run crontab -e and enter the following to make your bot to run every day at 00:00AM (midnight):

Notice: in these codes yourservicegroup is name of your service group (without "-local").