You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Help:Tool Labs/My first Pywikibot tool: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
imported>BryanDavis
(Update account creation and tool labs membership instructions phab:T53642)
imported>Xephyr826
Line 1: Line 1:
{{draft}}
{{draft}}
[[mw:Manual:Pywikibot|Pywikibot]] is a [[w:Python_(programming_language)|Python]] library which automates work on MediaWiki sites. Use this guide to create your own tool based on Pywikibot and host it on [[Help:Tool_Labs|Tool Labs]].
[[mw:Manual:Pywikibot|Pywikibot]] is a [[w:Python_(programming_language)|Python]] library which automates work on MediaWiki sites. Use this guide to create your own tool based on Pywikibot and host it on [[Help:Tool_Labs|Tool Labs]].
__TOC__


'''Tool Labs account required:'''
'''Tool Labs account required:'''
Line 6: Line 8:


==Create your Pywikibot Tool account==
==Create your Pywikibot Tool account==
In addition to your own Tool Labs account, you also need to create a [[Help:Tool_Labs#Joining_and_creating_a_Tool_account|Tool acoount]] for your Pywikibot tool.
# Navigate to the [[toollabs:|Tools home page]].
# Click '''Create a New Tool''' under '''Develop your own tool'''.
# Enter a Service group name. The Service group name will become the name of your tool account.<br/> Do not prefix your service group name with <code>tools.</code>. This prefix will cause an improperly created account. The management interface automatically adds this prefix where appropriate.
'''Note:''' If you only recently received access to the tools project, you may get an error about appropriate credentials. Log out of Wikitech and back in to fix the issue.


Within a minute or two, Tool Labs creates the Tool account and grants you access. If you were logged in through SSH when you created the Tool account, you must log off and log in again


==Access your Pywikibot tool==
==Access your Pywikibot tool==
Line 25: Line 35:


==Install Pywikibot==
==Install Pywikibot==
Using your tool account run the following:
Using your tool account, do the following:


<ol>
<ol>
<li>Use git to download Pywikibot:
<li>Use git to download Pywikibot:
<source>
<source>
git clone --recursive https://gerrit.wikimedia.org/r/pywikibot/core.git
git clone --recursive https://gerrit.wikimedia.org/r/pywikibot/core.git pywikibot-core
cd pywikibot-core
</source>
</source>
</li>
</li>
Line 42: Line 53:


==Choose a license==
==Choose a license==
Pywikibot comes with an MIT <tt>LICENSE</tt> file. Make sure to choose a license for your tool early on. Also see, [[Help:Tool_Labs/Developing#Licensing_your_source_code]]


==Publish your source code==
==Publish your source code==


==Create a documentation page==
==Create a documentation page==
===Create a documentation page for your tool===
===Set up a webpage for your tool===
You can add webpage for your tool under http://tools.wmflabs.org/TOOLNAME. For example, http://tools.wmflabs.org/my-first-pywikibot-tool. Once you set up a webpage for your tool, the [https://tools.wmflabs.org/?list Tool list] will link to it.
To set up webpage for you tool:
# Log in with your Tool account.
# Create a <tt>~/public_html</tt> directory.
# Create <tt>~/public_html/index.html</tt>.
# Start the web service:
<pre>
$ webservice start
</pre>

Revision as of 00:43, 15 May 2017

Pywikibot is a Python library which automates work on MediaWiki sites. Use this guide to create your own tool based on Pywikibot and host it on Tool Labs.

Tool Labs account required: Before creating your tool, you need to create an account to access Tool Labs. Set up your user name and shell name and submit a Tool Labs project membership request.

Create your Pywikibot Tool account

In addition to your own Tool Labs account, you also need to create a Tool acoount for your Pywikibot tool.

  1. Navigate to the Tools home page.
  2. Click Create a New Tool under Develop your own tool.
  3. Enter a Service group name. The Service group name will become the name of your tool account.
    Do not prefix your service group name with tools.. This prefix will cause an improperly created account. The management interface automatically adds this prefix where appropriate.

Note: If you only recently received access to the tools project, you may get an error about appropriate credentials. Log out of Wikitech and back in to fix the issue.

Within a minute or two, Tool Labs creates the Tool account and grants you access. If you were logged in through SSH when you created the Tool account, you must log off and log in again

Access your Pywikibot tool

After you create your Pywikibot's tool account, you can log into your tool project with SSH.

$ ssh <shell name>@login.tools.wmflabs.org

Switch to your tool account:

maintainer@tools-bastion:~$ become <toolname>
tools.<toolname>@tools-bastion:~$

Now, you can install Pywikibot.

Install Pywikibot

Using your tool account, do the following:

  1. Use git to download Pywikibot:
    git clone --recursive https://gerrit.wikimedia.org/r/pywikibot/core.git pywikibot-core
    cd pywikibot-core
  2. Set up your bot for selected wikis by running:
    python generate_user_files.py

Choose a license

Pywikibot comes with an MIT LICENSE file. Make sure to choose a license for your tool early on. Also see, Help:Tool_Labs/Developing#Licensing_your_source_code

Publish your source code

Create a documentation page

Create a documentation page for your tool

Set up a webpage for your tool

You can add webpage for your tool under http://tools.wmflabs.org/TOOLNAME. For example, http://tools.wmflabs.org/my-first-pywikibot-tool. Once you set up a webpage for your tool, the Tool list will link to it.

To set up webpage for you tool:

  1. Log in with your Tool account.
  2. Create a ~/public_html directory.
  3. Create ~/public_html/index.html.
  4. Start the web service:
$ webservice start