Page MenuHomePhabricator

SUL login fails if pywikibot is the first visit to the wiki
Closed, DuplicatePublic


When a user has not ever visited a wiki connected to SUL, attempting to pywikibot login will fail (P2372) as the account may not yet exist but will exist on login attempt.

tools.paws@jupyter-yuvipanda-test-account-44704412:~$ login                                                                 
Traceback (most recent call last):                                                                                                 
  File "/srv/pwb/", line 248, in <module>                                                                                    
    if not main():                                                                                                                 
  File "/srv/pwb/", line 242, in main                                                                                        
    run_python_file(filename, [filename] + args, argvu, file_package)                                                              
  File "/srv/pwb/", line 120, in run_python_file                                                                             
  File "/srv/pwb/scripts/", line 193, in <module>                                                                          
  File "/srv/pwb/scripts/", line 176, in main                                                                              
  File "/srv/pwb/pywikibot/", line 2004, in login                                                                           
    if loginMan.login(retry=True):                                                                                                 
  File "/srv/pwb/pywikibot/", line 265, in login                                                                           
  File "/srv/pwb/pywikibot/", line 140, in check_user_exists                                                               
    % (self.username,                                                                                                  
pywikibot.exceptions.NoUsername: Username 'Yuvipanda-test-account' does not exist on wikipedia:test                                
<class 'pywikibot.exceptions.NoUsername'>                                                                                          
CRITICAL: Closing network session.

Event Timeline

jayvdb raised the priority of this task from to High.
jayvdb updated the task description. (Show Details)
jayvdb added a subscriber: jayvdb.

Just ran into this. broke it. Work around is to comment out self.check_user_exists() on line 254

You linked to the merge commit and b96e4c8 is the actual commit which changed it. Anyway I think the only option (without undoing it) might be to detect that the site is using SUL and maybe ([[|query+globalallusers]]?) there is a way to query if there is a SUL user with that name.