Page MenuHomePhabricator

Regular disconnection of the bot
Closed, InvalidPublic

Description

I often have scripts (launched with cron via tool labs) that ask me for password, whereas I've logged in my bot once and for all, normally. Often, the bot works whitout asking for any password, sometimes he asks one. How can the bot disconnect ? What I can do to avoid that?

Here an example of error log:

Password for user Botomatik on wiktionary:fr
No characters will be shown: 
/usr/lib/python2.7/getpass.py:83: GetPassWarning: Can not control e
cho on the terminal.
  passwd = fallback_getpass(prompt, stream)
Warning: Password input may be echoed.
Traceback (most recent call last):
  File "pywikibot/pywikibot-compat/langues-json.py", line 270, in <module>
    maj_liste()
File "pywikibot/pywikibot-compat/langues-json.py", line 222, in maj_liste
    sauvegarde(Page_sortie, contenu, summary=u'Mise à jour automatique de la liste')
  File "pywikibot/pywikibot-compat/langues-json.py", line 246, in sauvegarde
    PageCourante.put(Contenu, summary, minorEdit=False)
  File "/data/project/botomatik/pywikibot/pywikibot-compat/wikipedia.py", line 2154, in put
    sysop=sysop)
  File "/data/project/botomatik/pywikibot/pywikibot-compat/wikipedia.py", line 2018, in _getActionUser
    self.site().forceLogin(sysop=sysop)
  File "/data/project/botomatik/pywikibot/pywikibot-compat/wikipedia.py", line 6722, in forceLogin
    if loginMan.login(retry=True):
  File "/data/project/botomatik/pywikibot/pywikibot-compat/login.py", line 337, in login
    password=True)
  File "/data/project/botomatik/pywikibot/pywikibot-compat/wikipedia.py", line 10307, in input
    data = ui.input(question, password)
  File "/data/project/botomatik/pywikibot/pywikibot-compat/userinterfaces/terminal_interface_base.py", line 140, in input
    text = getpass.getpass('')
  File "/usr/lib/python2.7/getpass.py", line 83, in unix_getpass
    passwd = fallback_getpass(prompt, stream)
  File "/usr/lib/python2.7/getpass.py", line 118, in fallback_getpass
    return _raw_input(prompt, stream)
  File "/usr/lib/python2.7/getpass.py", line 135, in _raw_input
    raise EOFError
EOFError

Thank you by advance

Event Timeline

Automatik raised the priority of this task from to Needs Triage.
Automatik updated the task description. (Show Details)
Automatik added a project: Pywikibot.
Automatik subscribed.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptJun 1 2015, 12:20 PM

You should set up a password file, where the password to the bot's account is stored.

See step 5 in https://wikitech.wikimedia.org/wiki/User:Russell_Blau/Using_pywikibot_on_Labs

Make sure to chmod 600 it, so that no one else can read it.

Step 5 says: "Create a file in your .pywikibot directory", but I don't have any .pywikibot directory. I just have "pywikibot"

Note that I use the compat branch, not the core.

jayvdb claimed this task.
jayvdb subscribed.

I am pretty confident that the password file can be in any directory, even with compat. Just put the location of the file into the user-config.py variable password_file.

And if you have problems, I strongly suggest that you migrate to using pywikibot-core. Come on IRC Pywikibot if you need help converting to pywikibot-core. Or send me your scripts via email and I will send you back a core version of the scripts.

jayvdb changed the task status from Resolved to Invalid.Jun 1 2015, 3:21 PM
jayvdb edited projects, added Pywikibot-compat; removed Pywikibot.
jayvdb set Security to None.

In the meantime I resolved the problem by adding the variable "password_file" to my user-config.py, and I'm going to migrate to core as soon as possible (via pywikibot/core/scripts/maintenance/compat2core.py (which is not complete since it does'nt convert function names when they are used via "from wikipedia import *"). Thank you for the aid proposal.