Page MenuHomePhabricator

pywikibot.exceptions.UserRightsError: User "None" does not have required user right "purge"
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue:

Run toolforge-jobs run purge --command "python3 $HOME/pywikibot-core/pwb.py touch.py -page:hu:Kezdőlap -purge" --image python3.9 on the bastion host.

(the same issue on local machine if run python pwb.py touch.py -page:hu:Kezdőlap -purge)

What happens?:
Received error message:

wrapping list type to a Generator type
WARNING: No user is logged in on site wikipedia:hu
Traceback (most recent call last):
  File "/data/project/ato/pywikibot-core/pwb.py", line 39, in <module>
    sys.exit(main())
  File "/data/project/ato/pywikibot-core/pwb.py", line 35, in main
    runpy.run_path(str(path), run_name='__main__')
  File "/usr/lib/python3.9/runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/data/project/ato/pywikibot-core/pywikibot/scripts/wrapper.py", line 516, in <module>
    main()
  File "/data/project/ato/pywikibot-core/pywikibot/scripts/wrapper.py", line 500, in main
    if not execute():
  File "/data/project/ato/pywikibot-core/pywikibot/scripts/wrapper.py", line 487, in execute
    run_python_file(filename, script_args, module)
  File "/data/project/ato/pywikibot-core/pywikibot/scripts/wrapper.py", line 147, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File "/data/project/ato/pywikibot-core/scripts/touch.py", line 168, in <module>
    main()
  File "/data/project/ato/pywikibot-core/scripts/touch.py", line 164, in main
    bot_class(generator=gen, **options).run()
  File "/data/project/ato/pywikibot-core/pywikibot/bot.py", line 1715, in run
    self.exit()
  File "/data/project/ato/pywikibot-core/pywikibot/bot.py", line 1554, in exit
    self.teardown()
  File "/data/project/ato/pywikibot-core/scripts/touch.py", line 105, in teardown
    self.purgepages(flush=True)
  File "/data/project/ato/pywikibot-core/scripts/touch.py", line 120, in purgepages
    done = site.purgepages(pagelist, **self.opt)
  File "/data/project/ato/pywikibot-core/pywikibot/site/_decorators.py", line 89, in callee
    raise UserRightsError('User "{}" does not have required '
pywikibot.exceptions.UserRightsError: User "None" does not have required user right "purge"
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.UserRightsError'>

What should have happened instead?:

Atobot's last run was succesfull on 2023.01.23 on the bastion host:

Retrieving 1 pages from wikipedia:hu.
Sleeping for 9.5 seconds, 2023-01-21 23:01:15
Page [[hu:Kezdőlap]] purged

1 read operation
1 purge operation
Execution time: 10 seconds
Read operation time: 10.0 seconds
Purge operation time: 10.0 seconds
Script terminated successfully.

Software version :

Pywikibot: [https] r-pywikibot-core.git (a85ea67, g1, 2022/09/26, 14:17:39, stable)
Release version: 7.7.0
setuptools version: 40.8.0
mwparserfromhell version: 0.6.3
wikitextparser version: n/a
requests version: 2.21.0
  cacerts: /etc/ssl/certs/ca-certificates.crt
    certificate test: ok
Python: 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0]
PYWIKIBOT_DIR: Not set
PYWIKIBOT_DIR_PWB: /shared/pywikibot/stable
PYWIKIBOT_NO_USER_CONFIG: Not set
Config base dir: /data/project/ato/.pywikibot
Usernames for family 'wikipedia':
	hu: atobot

Event Timeline

JJMC89 subscribed.

The version information you reported does not match the python version from the toolforge-jobs command (3.9) or the pywikibot version checked out in /data/project/ato/pywikibot-core (8.0.0).

The message indicates that your bot is not logged in. That is likely caused by the removal of pywikibot.Site().login() in {b283f4d}.

Change 884429 had a related patch set uploaded (by JJMC89; author: JJMC89):

[pywikibot/core@master] restore login

https://gerrit.wikimedia.org/r/884429

The version information you reported does not match the python version from the toolforge-jobs command (3.9) or the pywikibot version checked out in /data/project/ato/pywikibot-core (8.0.0).

The message indicates that your bot is not logged in. That is likely caused by the removal of pywikibot.Site().login() in {b283f4d}.

I have checked the version in this way:
toolforge-jobs run version --command "python3 $HOME/pywikibot-core/pwb.py version.py" --image python3.9

...and received as follows:
Pywikibot: [https] r-pywikibot-core (b678f2e, g17785, 2023/01/21, 12:29:25, stable)
Release version: 8.0.0
setuptools version: 66.1.1
mwparserfromhell version: 0.6.4
wikitextparser version: n/a
requests version: 2.28.2

cacerts: /data/project/ato/.local/lib/python3.9/site-packages/certifi/cacert.pem
  certificate test: ok

Python: 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]
PYWIKIBOT_DIR: Not set
PYWIKIBOT_DIR_PWB: /data/project/ato/pywikibot-core/pywikibot/scripts
PYWIKIBOT_NO_USER_CONFIG: Not set
Config base dir: /data/project/ato/.pywikibot
Usernames for family 'wikipedia':
hu: atobot

Xqt assigned this task to JJMC89.

Change 884429 merged by jenkins-bot:

[pywikibot/core@master] restore login

https://gerrit.wikimedia.org/r/884429