Manual:Pywikibot/login.py
Wikimedia Git repository has this file: scripts/login.py |
login.py is the python program that logs the user running the pywikibot on to the system using the data that can be found in user-config.py .
Salir como bot
Bots provide specified result and as a consequence, they should not need the attention that other changes require. By having a specific user to run the bot software, the changes created in this way will be hidden on a typical recent changes screen. Bot status is given when a community is in favour with someone running a bot.
Como saber dónde acceder
En el archivo user-config.py hay tres componentes:
- El idioma: mylang
- La familia: familia - esto indica el nombre de la wiki, incluyendo wikipedia o wiktionary
- the username: username - this can be any user but it should be a user who is registered to run as a bot.
In order to login to all the projects/languages mentioned in user-config.py, the option -all
can be used, and if the same password is used throughout all these projects, it can be combined with -pass
so that the program doesn't ask for a password for each site.
$ python pwb.py login -all -pass
acceder en todos los proyectos en user-config.py, utilizando la misma contraseña para todo. Por ahora, utilizando la opción de pase no es apoyada. (T102477) You should use password file instead. Create file with text like '("en", "wikipedia", "User", "password")' (you can use more than one line). Then, insert in your user-config.py file 'password_file = "path_to_password_file"' line. After this Pywikibot should use data from this file when he need to login. You should make user-config.py and password file unreadable for others (chmod 600 user-config.py) before adding secrets to it.
Salir
$ python pwb.py login -logout
Salir utilizando OAuth
Pywikibot supports login using OAuth authentication instead of password. The OAuth feature needs the site with Extension:OAuth installed and configured properly. OAuth is more secure (passwords are not sent over the internet, can be invalidated at any time, and the permissions of the bot user can be restricted) and should generally be preferred over normal login. See Manual:Pywikibot/OAuth on how to use it (it does not involve login.py).
If for some reason you want to log your bot in as a multi-user OAuth app (not recommended, but e.g. older MediaWiki might not support owner-only apps), you can use login.py for that, with the option -oauth
.
The process contains the following steps:
- Log into meta as your bot account. Create an OAuth app at
Special:OAuthConsumerRegistration/propose
if it does not exist yet, and record the consumer key and secret. Until T323849 is resolved, only version 1.0a is supported
- Run
python pwb.py login -oauth
- Input OAuth consumer key
- Input OAuth consumer secret
- Authenticate user via web browser. You may need to manually copy the url from the terminal if the web browser doesn't open up automatically.
- Input response query string to terminal when authentication succeeds.
P. ej.: oauth_verifier=xxx&oauth_token=yyy
- Copy and paste authentication entry generated into user-config.py .
-logout
, -pass
, -force
, -pass:XXXX
and -sysop
are not compatible with -oauth
.
Opciones disponibles
Esta página está desactualizada. |
Estas opciones ignoran la configuración dada en user-config.py .
Parámetro | Descripción | Config variable |
---|---|---|
-dir:PATH |
Read the bot's configuration data from directory given by PATH, instead of from the default directory. | |
-config:file |
The user config filename. Default is user-config.py. | user-config.py |
-lang:xx |
Set the language of the wiki you want to work on, overriding the configuration in user-config.py. xx should be the language code. | mylang |
-family:xyz |
Set the family of the wiki you want to work on, e.g. wikipedia, wiktionary, wikitravel, ... This will override the configuration in user-config.py. | family |
-user:xyz |
Inicia sesión como el usuario 'xyz' en vez de con el usuario por defecto. | usernames |
-daemonize:xyz |
Immediately return control to the terminal and redirect stdout and stderr to file xyz. (only use for bots that require no input from stdin). | |
-help |
Show the help text. | |
-log |
Enable the log file, using the default filename 'script_name-bot.log' Logs will be stored in the logs subdirectory. | log |
-log:xyz |
Enable the log file, using 'xyz' as the filename. | logfilename |
-nolog |
Disable the log file (if it is enabled by default). | |
-maxlag |
Sets a new maxlag parameter to a number of seconds. Defer bot edits during periods of database server lag. Default is set by config.py | maxlag |
-putthrottle:n -pt:n -put_throttle:n |
Set the minimum time (in seconds) the bot will wait between saving pages. | put_throttle |
-debug:item -debug |
Enable the log file and include extensive debugging data for component "item" (for all components if the second form is used). | debug_log |
-verbose -v |
Have the bot provide additional console output that may be useful in debugging. | verbose_output |
-cosmeticchanges -cc |
Toggles the cosmetic_changes setting made in config.py or user-config.py to its inverse and overrules it. All other settings and restrictions are untouched. | cosmetic_changes |
-simulate |
Disables writing to the server. Useful for testing and debugging of new code (if given, doesn't do any real changes, but only shows what would have been changed). | simulate |
-<config var>:n |
You may use all given numeric config variables as option and modify it with command line. |