Pywikibot/Installing: Difference between revisions
From charlesreid1
(Created page with "==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 W...") |
|||
| (6 intermediate revisions by the same user not shown) | |||
| Line 5: | Line 5: | ||
Link to pywikibot on Wikimedia Foundation's gerrit: https://gerrit.wikimedia.org/r/pywikibot/core.git | 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 | Link to pywikibot on git.charlesreid1.com: https://git.charlesreid1.com/wiki/pywikibot | ||
===Wikimedia gerrit=== | ===Wikimedia gerrit=== | ||
| Line 30: | Line 30: | ||
</pre> | </pre> | ||
===Set up a family file=== | |||
Before logging into a new wiki family, you need to create a family file for that wiki "family". | |||
Use the <code>generate_family_file.py</code> script to do that: | |||
<pre> | |||
$ python generate_family_file.py <url-of-wiki> <wiki-shortname> | |||
</pre> | |||
For example, | |||
<pre> | <pre> | ||
$ | $ python generate_family_file.py https://charlesreid1.com/wiki/Main_Page charlesreid1 | ||
</pre> | </pre> | ||
This | This will generate a family file at <code>pywikibot/families/charlesreid1_family.py</code> with the contents: | ||
<pre> | <pre> | ||
# -*- coding: utf-8 -*- | |||
""" | |||
This family file was auto-generated by generate_family_file.py script. | |||
Configuration parameters: | |||
url = https://charlesreid1.com/wiki/Main_Page | |||
name = charlesreid1 | |||
Please do not commit this to the Git repository! | |||
""" | |||
from __future__ import absolute_import, division, unicode_literals | |||
from pywikibot import family | from pywikibot import family | ||
from pywikibot.tools import deprecated | |||
class Family(family.Family): | |||
def | class Family(family.Family): # noqa: D101 | ||
name = 'charlesreid1' | |||
self | langs = { | ||
'en': ' | 'en': 'charlesreid1.com', | ||
} | } | ||
def scriptpath(self, code): | |||
return { | |||
'en': '/w', | |||
}[code] | |||
@deprecated('APISite.version()') | |||
def version(self, code): | |||
return { | |||
'en': '1.30.0', | |||
}[code] | |||
def protocol(self, code): | |||
return { | |||
'en': 'https', | |||
}[code] | |||
</pre> | </pre> | ||
NOTE: The family file name MUST end with <code>_family</code> or it will not get picked up by the login script. | |||
The first time you run the login action script, you will be asked to set up some details about the wiki family that you have selected: | |||
<pre> | |||
$ py pwb.py login | |||
NOTE: 'user-config.py' was not found! | |||
Please follow the prompts to create it: | |||
You can abort at any time by pressing ctrl-c | |||
Now you should be able to log into the wiki as your bot: | Your default user directory is "/home/charles/codes/wiki/pywikibot" | ||
1: charlesreid1 | |||
2: commons | |||
3: i18n | |||
4: incubator | |||
... | |||
Select family of sites we are working on, just enter the number or name (default: wikipedia): 1 | |||
The only known language: en | |||
The language code of the site we're working on (default: en): en | |||
Username on en:charlesreid1: Admin | |||
Do you want to add any other projects? ([y]es, [N]o): n | |||
'/home/charles/codes/wiki/pywikibot/user-config.py' written. | |||
Now, you have to re-execute the command to start your script. | |||
</pre> | |||
Now run the login action script again, and you should be able to log into the wiki as your bot: | |||
<pre> | <pre> | ||
| Line 69: | Line 127: | ||
===git.charlesreid1.com=== | ===git.charlesreid1.com=== | ||
Link to pywikibot on git.charlesreid1.com: https://charlesreid1.com | Link to pywikibot on git.charlesreid1.com: https://git.charlesreid1.com/wiki/pywikibot | ||
To push changes to the pywikibot on git.charlesreid1.com I set up the repo with another remote: | To push changes to the pywikibot on git.charlesreid1.com I set up the repo with another remote: | ||
<pre> | <pre> | ||
$ git remote add cmr https://charlesreid1.com | $ git remote add cmr https://git.charlesreid1.com/wiki/pywikibot | ||
$ git push cmr master | $ git push cmr master | ||
</pre> | </pre> | ||
==Flags== | |||
==Flags= | |||
[[Category:Pywikibot]] | [[Category:Pywikibot]] | ||
Latest revision as of 19:27, 6 October 2019
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://git.charlesreid1.com/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
Before logging into a new wiki family, you need to create a family file for that wiki "family".
Use the generate_family_file.py script to do that:
$ python generate_family_file.py <url-of-wiki> <wiki-shortname>
For example,
$ python generate_family_file.py https://charlesreid1.com/wiki/Main_Page charlesreid1
This will generate a family file at pywikibot/families/charlesreid1_family.py with the contents:
# -*- coding: utf-8 -*-
"""
This family file was auto-generated by generate_family_file.py script.
Configuration parameters:
url = https://charlesreid1.com/wiki/Main_Page
name = charlesreid1
Please do not commit this to the Git repository!
"""
from __future__ import absolute_import, division, unicode_literals
from pywikibot import family
from pywikibot.tools import deprecated
class Family(family.Family): # noqa: D101
name = 'charlesreid1'
langs = {
'en': 'charlesreid1.com',
}
def scriptpath(self, code):
return {
'en': '/w',
}[code]
@deprecated('APISite.version()')
def version(self, code):
return {
'en': '1.30.0',
}[code]
def protocol(self, code):
return {
'en': 'https',
}[code]
NOTE: The family file name MUST end with _family or it will not get picked up by the login script.
The first time you run the login action script, you will be asked to set up some details about the wiki family that you have selected:
$ py pwb.py login NOTE: 'user-config.py' was not found! Please follow the prompts to create it: You can abort at any time by pressing ctrl-c Your default user directory is "/home/charles/codes/wiki/pywikibot" 1: charlesreid1 2: commons 3: i18n 4: incubator ... Select family of sites we are working on, just enter the number or name (default: wikipedia): 1 The only known language: en The language code of the site we're working on (default: en): en Username on en:charlesreid1: Admin Do you want to add any other projects? ([y]es, [N]o): n '/home/charles/codes/wiki/pywikibot/user-config.py' written. Now, you have to re-execute the command to start your script.
Now run the login action script again, and 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://git.charlesreid1.com/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://git.charlesreid1.com/wiki/pywikibot $ git push cmr master