Pywikibot/Installing: Difference between revisions
From charlesreid1
(→=Flags) |
|||
| Line 29: | Line 29: | ||
$ git submodule update --init | $ git submodule update --init | ||
</pre> | </pre> | ||
==Set up a family file== | |||
Add a custom family file to the big directory of family files: | Add a custom family file to the big directory of family files: | ||
| Line 55: | Line 57: | ||
Copy and paste this into <code>pwb/pywikibot/families/charlesreid1_family.py</code> (where pwb is the name of the directory where you checked out the git repository). | Copy and paste this into <code>pwb/pywikibot/families/charlesreid1_family.py</code> (where pwb is the name of the directory where you checked out the git repository). | ||
NOTE: The family file name MUST end with <code>_family</code> or it will not get picked up by the login script. | |||
Now you should be able to log into the wiki as your bot: | Now you should be able to log into the wiki as your bot: | ||
Revision as of 21:55, 1 February 2018
Installing Pywikibot
I have the pywikibot software set up with two remotes: one official (Wikimedia gerrit), and one unofficial (my own git repo).
Link to pywikibot on Wikimedia Foundation's gerrit: https://gerrit.wikimedia.org/r/pywikibot/core.git
Link to pywikibot on git.charlesreid1.com: https://charlesreid1.com:3000/wiki/pywikibot
Wikimedia gerrit
Note the official pywikibot repo is also cloned on Github: https://github.com/wikimedia/pywikibot-core/
Start by checking it out:
$ git clone https://gerrit.wikimedia.org/r/pywikibot/core.git pywikibot $ cd pywikibot
Install all the pip stuff that you may need:
$ pip install -r requirements.txt
Update git submodules:
$ git submodule update --init
Set up a family file
Add a custom family file to the big directory of family files:
$ ls pywikibot/families ... wikivoyage_family.py wiktionary_family.py wowwiki_family.py
This is where you will put your custom family file. Here's what the custom family file looks like:
from pywikibot import family
class Family(family.Family):
def __init__(self):
family.Family.__init__(self)
self.name = 'charlesreid1'
self.langs = {
'en': 'charlesreid1.com',
}
Copy and paste this into pwb/pywikibot/families/charlesreid1_family.py (where pwb is the name of the directory where you checked out the git repository).
NOTE: The family file name MUST end with _family or it will not get picked up by the login script.
Now you should be able to log into the wiki as your bot:
$ python pwb.py login Password for user Bleep bloop on charlesreid1:en (no characters will be shown): Logging in to charlesreid1:en as Bleep bloop WARNING: /Users/charles/codes/pywikibot/pywikibot/tools/__init__.py:1717: UserWarning: File /Users/charles/codes/pywikibot/pywikibot.lwp had 644 mode; converted to 600 mode. Logged in on charlesreid1:en as Bleep bloop.
git.charlesreid1.com
Link to pywikibot on git.charlesreid1.com: https://charlesreid1.com:3000/wiki/pywikibot
To push changes to the pywikibot on git.charlesreid1.com I set up the repo with another remote:
$ git remote add cmr https://charlesreid1.com:3000/wiki/pywikibot $ git push cmr master