Page MenuHomePhabricator

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

Description

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

Event Timeline

jayvdb created this task.Dec 4 2015, 12:50 AM
jayvdb raised the priority of this task from to High.
jayvdb updated the task description. (Show Details)
jayvdb added a subscriber: jayvdb.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptDec 4 2015, 12:50 AM

Just ran into this. https://phabricator.wikimedia.org/rPWBC261aa028acb1fda727f7ee3418c5fd8db189bc6a broke it. Work around is to comment out self.check_user_exists() on line 254

XZise added a subscriber: XZise.Jan 13 2016, 9:40 PM

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 ([[https://test.wikidata.org/w/api.php?action=help&modules=query%2Bglobalallusers|query+globalallusers]]?) there is a way to query if there is a SUL user with that name.