Page MenuHomePhabricator

pywikibot.exceptions.NoUsername should not happen if user type incorrect password when use login.py script
Closed, ResolvedPublicBUG REPORT

Description

Steps to Reproduce:

  1. Run python pwb.py login
  2. Type incorrect password

Actual Results:
You will get this:

1zoran@zoran-notebook:~/development/core$ nano user-config.py
2zoran@zoran-notebook:~/development/core$ python3 pwb.py login
3Password for user Zoranzoki21 on wikipedia:sr (no characters will be shown):
4Logging in to wikipedia:sr as Zoranzoki21
5ERROR: Login failed (Failed).
6Traceback (most recent call last):
7 File "/home/zoran/development/core/pywikibot/login.py", line 313, in login
8 cookiedata = self.getCookie()
9 File "/home/zoran/development/core/pywikibot/tools/__init__.py", line 1823, in wrapper
10 return obj(*new_args, **new_kwargs)
11 File "/home/zoran/development/core/pywikibot/data/api.py", line 3301, in getCookie
12 raise APIError(code=login_result['login']['result'], info=info)
13pywikibot.data.api.APIError: Failed: Incorrect username or password entered. Please try again.
14
15During handling of the above exception, another exception occurred:
16
17Traceback (most recent call last):
18 File "pwb.py", line 257, in <module>
19 if not main():
20 File "pwb.py", line 250, in main
21 run_python_file(filename, [filename] + args, argvu, file_package)
22 File "pwb.py", line 119, in run_python_file
23 main_mod.__dict__)
24 File "./scripts/login.py", line 198, in <module>
25 main()
26 File "./scripts/login.py", line 180, in main
27 site.login(sysop, autocreate=autocreate)
28 File "/home/zoran/development/core/pywikibot/site.py", line 2104, in login
29 if login_manager.login(retry=True, autocreate=autocreate):
30 File "/home/zoran/development/core/pywikibot/login.py", line 329, in login
31 '{1}\n.{2}'.format(self.login_name, self.site, e.info))
32pywikibot.exceptions.NoUsername: Username "Zoranzoki21" does not have read permissions on wikipedia:sr
33.Incorrect username or password entered. Please try again.
34<class 'pywikibot.exceptions.NoUsername'>
35CRITICAL: Closing network session.
36zoran@zoran-notebook:~/development/core$

Expected Results:
pywikibot.exceptions.NoUsername should not happen and output should be something like this:

1zoran@zoran-notebook:~/development/core$ nano user-config.py
2zoran@zoran-notebook:~/development/core$ python3 pwb.py login
3Password for user Zoranzoki21 on wikipedia:sr (no characters will be shown):
4Logging in to wikipedia:sr as Zoranzoki21
5ERROR: Login failed (Failed). Incorrect username or password entered. Please try again.
6Password for user Zoranzoki21 on wikipedia:sr (no characters will be shown):

Version:

1zoran@zoran-notebook:~/development/core$ python3 pwb.py version
2Pywikibot: [ssh] pywikibot-core (73f07ba, g10390, 2018/11/09, 09:23:55, ok)
3Release version: 3.1.dev0
4requests version: 2.18.4
5 cacerts: /etc/ssl/certs/ca-certificates.crt
6 certificate test: ok
7Python: 3.6.6 (default, Sep 12 2018, 18:26:19)
8[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
9PYWIKIBOT_DIR: Not set
10PYWIKIBOT_DIR_PWB:
11PYWIKIBOT_NO_USER_CONFIG: Not set
12Config base dir: /home/zoran/development/core
13Usernames for family "wikipedia":
14 sr: Zoranzoki21 (no sysop configured)
15Usernames for family "translatewiki":
16 en: Zoranzoki21-Bot (no sysop configured)
17Usernames for family "testwiki":
18 sr: Zoranzoki21 (also sysop)
19zoran@zoran-notebook:~/development/core$

Event Timeline

Xqt triaged this task as Low priority.Nov 9 2018, 10:44 PM

Could you check if this is still happenning?

Could you check if this is still happenning?

@Dvorapa Hello, this happens now:

kizule@kizule-laptop1:~/Desktop/development/pywikibot-core$ python pwb.py login
WARNING: No user is logged in on site wikipedia:sr
Password for user Zoranzoki21 on wikipedia:sr (no characters will be shown): 
Logging in to wikipedia:sr as Zoranzoki21
ERROR: Login failed (FAIL).
Traceback (most recent call last):
  File "/home/kizule/Desktop/development/pywikibot-core/pywikibot/login.py", line 300, in login
    cookiedata = self.getCookie()
  File "/home/kizule/Desktop/development/pywikibot-core/pywikibot/tools/__init__.py", line 1882, in wrapper
    return obj(*new_args, **new_kwargs)
  File "/home/kizule/Desktop/development/pywikibot-core/pywikibot/data/api.py", line 3222, in getCookie
    raise APIError(code=status, info=info)
pywikibot.data.api.APIError: FAIL: Унели сте неисправно корисничко име или лозинку.
Покушајте поново.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pwb.py", line 390, in <module>
    if not main():
  File "pwb.py", line 382, in main
    run_python_file(filename,
  File "pwb.py", line 100, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File "./scripts/login.py", line 188, in <module>
    main()
  File "./scripts/login.py", line 170, in main
    site.login(autocreate=autocreate)
  File "/home/kizule/Desktop/development/pywikibot-core/pywikibot/tools/__init__.py", line 1797, in wrapper
    return obj(*__args, **__kw)
  File "/home/kizule/Desktop/development/pywikibot-core/pywikibot/site/__init__.py", line 2089, in login
    if login_manager.login(retry=True, autocreate=autocreate):
  File "/home/kizule/Desktop/development/pywikibot-core/pywikibot/login.py", line 309, in login
    raise NoUsername(error_msg)
pywikibot.exceptions.NoUsername: Username "Zoranzoki21" does not have read permissions on wikipedia:sr
.Унели сте неисправно корисничко име или лозинку.
Покушајте поново.
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.NoUsername'>
kizule@kizule-laptop1:~/Desktop/development/pywikibot-core$

python pwb.py version:

kizule@kizule-laptop1:~/Desktop/development/pywikibot-core$ python pwb.py version
Pywikibot: [ssh] pywikibot-core (bf2effc, g12283, 2020/04/10, 18:35:09, ok)
Release version: 3.1.dev0
requests version: 2.22.0
  cacerts: /etc/ssl/certs/ca-certificates.crt
    certificate test: ok
Python: 3.8.2 (default, Mar 13 2020, 10:14:16) 
[GCC 9.3.0]
PYWIKIBOT_DIR: Not set
PYWIKIBOT_DIR_PWB: 
PYWIKIBOT_NO_USER_CONFIG: Not set
Config base dir: /home/kizule/Desktop/development/pywikibot-core
Usernames for family "wikidata":
        wikidata: Zoranzoki21
Usernames for family "wikisource":
        sr: Zoranzoki21
Usernames for family "wikipedia":
        sr: Zoranzoki21
Usernames for family "wikiquote":
        sr: Zoranzoki21
Usernames for family "wikibooks":
        sr: Zoranzoki21
Usernames for family "wiktionary":
        sr: Zoranzoki21
        hr: Zoranzoki21
Usernames for family "wikinews":
        sr: Zoranzoki21
kizule@kizule-laptop1:~/Desktop/development/pywikibot-core$
Xqt claimed this task.
Xqt subscribed.

This is already solved:

Password for user Xqtest on wikipedia:de (no characters will be shown):
Logging in to wikipedia:de as Xqtest
ERROR: Username 'Xqtest' does not have read permissions on wikipedia:de.
Das Passwort und/oder das Sicherheitswort (CAPTCHA) ist falsch oder wurde nicht eingegeben. Bitte versuche es erneut oder lass dir das Passwort per E-Mail zurücksetzen. Du kannst auch [[Special:Userlogin/signup|ein neues Benutzerkonto erstellen]].
Not logged in on wikipedia:de.

Execution time: 4 seconds