Hello everyone,
My name is Ananta Vaishnavi, and I'm new to the Mediawiki community. I'm
reaching out today because I've encountered an issue while trying to set up
pywiki bot on my local device.
Despite logging in, I'm receiving an error message that says I haven't
logged in to Wikipedia. Specifically, the error message states that there
is no user logged in on site wikipedia:en and that my username
'AVaishnaviM' does not exist on Wikipedia. I've included a screenshot of
the error message at https://ctrlv.link/uqXv and a screenshot of my
Wikipedia https://ctrlv.link/POj4 account for reference.
To troubleshoot this issue, I have already tried logging out and logging
back in to Mediawiki. I have also attempted to perform the commands again,
but unfortunately, the same error message persists.
For additional context, I'm using Windows 11 64 bit, and the version of
pywiki bot that I'm using is the latest version.
Can you please help me with this issue?
My bot needs to be able to run as either of two different accounts depending on the task. DYKToolsBot for most things, DYKToolsAdminBot for specific tasks that need admin rights. How do I do this?
I'm not using the pwb.py driver layer; I've got my own top-level driver code and just import pywikibot as a library.
I thinking maybe I want to use PYWIKIBOT_NO_USER_CONFIG=2 and ignore the user-config.py stuff completely, but it's not clear how I pass the config into the library. Family and mylang are easy; I just pass those directly to pywikibot.Site(). But It's not clear what to do with username and the OAuth credentials that are currently in authenticate[]. Do I just create a login.OauthLoginManager and call login() on that?
Folks, I really made a lot of effort, even asked somebody to help IRL, but
I am tired.
I want develop Pywikibot, instead I am struggling with the working
environment. Although git is hundred times as complicated as SVN and gerrit
is a nightmare, my main problem is with git installing i18n submodule.
See https://phabricator.wikimedia.org/T329452
It causes two main problems:
- I cannot run tests. I have another copy of Pywikibot from downloaded
zip, I can run tests there, but the same command fails in git copy.
- I cannot push my commits. For some reason an i18n part is always
included which makes Jenkins fail. Now I can remove it after pushing, but
Jenkins fails again, see
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/888745
Error message:
https://integration.wikimedia.org/ci/job/pywikibot-core-tox-doctest-docker/…
: FAILURE in 33s
I am very frustrated and disappointed, but I cannot do anything until
T329452 is solved somehow.
--
Bináris
https://www.mediawiki.org/wiki/Manual:Pywikibot/Development/Guidelines#Misc…
says:
" Prefer f-strings over string.format(). Modulo operator % for string
formatting should be avoided."
I tried to rewrite a modulo-formatted regex to f-string, but than realized,
that in f-strings all curly braces must be doubled, which makes regexes
very hard to read and easy to misspell.
What is the best practice when you substitute a variable into a regex?
--
Bináris
I tried to list delete log entries:
from pywikibot.data.api import LogEntryListGenerator
gen = LogEntryListGenerator('delete')
print(next(gen))
I get a wirning and an error:
WARNING: c:\Pywikibot\pywikibot\data\api\_generators.py:857: *RuntimeWarning:
LogEntryListGenerator invoked without a site*
super().__init__('logevents', **kwargs)
Traceback (most recent call last):
File "pwb.py", line 39, in <module>
sys.exit(main())
File "pwb.py", line 35, in main
runpy.run_path(str(path), run_name='__main__')
File "C:\Python37\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Python37\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "pywikibot\scripts\wrapper.py", line 516, in <module>
main()
File "pywikibot\scripts\wrapper.py", line 500, in main
if not execute():
File "pywikibot\scripts\wrapper.py", line 487, in execute
run_python_file(filename, script_args, module)
File "pywikibot\scripts\wrapper.py", line 148, in run_python_file
main_mod.__dict__)
File "scripts\userscripts\reasonstat.py", line 141, in <module>
main()
File "scripts\userscripts\reasonstat.py", line 112, in main
print(next(gen))
File "C:\Python37\lib\_collections_abc.py", line 317, in __next__
return self.send(None)
File "c:\Pywikibot\pywikibot\tools\collections.py", line 275, in send
return next(self._started_gen)
File "c:\Pywikibot\pywikibot\data\api\_generators.py", line 628, in
generator
yield from self._extract_results(resultdata)
File "c:\Pywikibot\pywikibot\data\api\_generators.py", line 572, in
_extract_results
result = self.result(item)
File "c:\Pywikibot\pywikibot\data\api\_generators.py", line 864, in result
return self.entryFactory.create(pagedata)
File "c:\Pywikibot\pywikibot\logentries.py", line 339, in create
return self._creator(logdata)
File "c:\Pywikibot\pywikibot\logentries.py", line 329, in <lambda>
self._creator = lambda data: logclass(data, self._site)
File "c:\Pywikibot\pywikibot\logentries.py", line 42, in __init__
.format(expected_type, self.type()))
*pywikibot.exceptions.Error: Wrong log type! Expecting delete, received
review instead.CRITICAL: Exiting due to uncaught exception <class
'pywikibot.exceptions.Error'>*
What's wrong?
--
Bináris