Traceback (most recent call last):
File "/data/data/com.termux/files/home/vikaspy/pwb.py", line 399, in
<module>
if not main():
File "/data/data/com.termux/files/home/vikaspy/pwb.py", line 391, in main
run_python_file(filename,
File "/data/data/com.termux/files/home/vikaspy/pwb.py", line 106, in
run_python_file
exec(compile(source, filename, 'exec', dont_inherit=True),
File "./scripts/replace.py", line 1075, in <module>
main()
File "./scripts/replace.py", line 929, in main
single_summary = i18n.twtranslate(
File
"/data/data/com.termux/files/home/vikaspy/pywikibot/tools/_deprecate.py",
line 404, in wrapper
return obj(*__args, **__kw)
File "/data/data/com.termux/files/home/vikaspy/pywikibot/i18n.py", line
700, in twtranslate
raise pywikibot.exceptions.TranslationError(
pywikibot.exceptions.TranslationError: Unable to load messages package
scripts.i18n for bundle replace-replacing
It can happen due to lack of i18n submodule or files. See
https://www.mediawiki.org/wiki/Manual:Pywikibot/i18n
CRITICAL: Exiting due to uncaught exception <class
'pywikibot.exceptions.TranslationError'>
$
I never thought I'd ever write this, but after close to 40 years of using emacs for everything, I'm thinking of switching to a real IDE for python development. My latest evolution is emacs with elpy, which is pretty powerful as these things go, but I seem to spend more time configuring emacs and less time writing code than I want to. I got clarity on this the other day when I was comparing the toolforge bastion hosts, the cloud VPS images, and the kubernetes back ends to see which versions of emacs each one had and realized this really was the tail wagging the dog.
I'm kind of in "big paradigm shift" mode right now. Moving from Django to Flask. From mwclient to pywikibot. From unittest to pytest. I guess since I'm reinventing the universe, I might as well look at editors too. Other than the basic syntax coloring and auto-completion, I'm looking for good integrations with running unit tests and with git. I also need support for web technologies like HTML, jinja templates, and javascript in the same tool.
I've heard good things about Sublime, but never used it. I'm not averse to purchasing a license if it's worth it.
I've used Eclipse in the past for Java, and was pretty happy with that. I gather that Eclipse + PyDev is pretty neat but never tried it.
I know a lot of people live in Jupyter, but that's not really my style.
What else should I be looking at? What are folks out there using?
Where are the logins stored? In compat they had an obvious directory. Now I
searched it a lot, but did not find.
Whenever I run login.py, the previous account is thrown out, so I cannot
comfortably use two accounts. Is it on purpose?
--
Bináris
I've got:
platform darwin -- Python 3.9.13, pytest-7.2.0, pluggy-1.0.0
rootdir: /Users/roy/dev/dyk-tools, configfile: src/pages/pytest.ini
plugins: mock-3.10.0, socket-0.5.1
When I run the following:
def test_ip(mocker):
mock_IPv4Address = mocker.patch('ipaddress.IPv4Address', autospec=True)
ip = mock_IPv4Address('1.2.3.4')
assert mock_IPv4Address.xxyyzz
def test_site(mocker):
mock_Site = mocker.patch('pywikibot.Site', autospec=True)
site = mock_Site('en', 'wikipedia')
assert site.xxyyzz
test_ip() fails, as I expect it to, with AttributeError: Mock object has no attribute 'xxyyzz'. But, test_site() passes. WTF? Why does it not also fail with the same error?
python pwb.py -nolog -user:Bináris userpageprotect.py
python pwb.py -nolog -user:"Bináris" userpageprotect.py
Neither asks for my password when the script wants to protect a page. (The
script is own development.)
Instead I get:
pywikibot.exceptions.UserRightsError: User "None" does not have required
user right "protect"
CRITICAL: Exiting due to uncaught exception <class
'pywikibot.exceptions.UserRightsError'>
Do I do soemthing wrong?
I liked the compat solution with my sysop user in user-config much better.
:-(
--
Bináris
I'm diving into my first serious PWB application. I'm using it as a library to replace mwclient.
I'm not sure how to approach testing. I'd really like something which is isolated from making actual API calls (i.e. hermetic unit tests). Does there exist a mechanism to do that?
What I've been doing so far is using unittest.mock to create mock Page objects, but that's not wondeful. unitest.mock is always a little clunky to use, but more than that, it's too easy to create mocks that don't accurately emulate the real PWB behaviors, so your tests aren't really testing what they should be. The other problem is if you don't mock every possible code path to the backend API, you can end up hitting a real server by accident during your tests. Which we be not a good thing.
How do people handle this?
Hi,
I write scripts, mostly for temporary tasks. I understand, that pwb.py
handles arguments and logs and finds my script in /scripts/userscripts.
Most of these scripts don't excpect arguments, the task is wired in. So is
there any advantage of using pwb.py in this case?
--
Bináris
ERROR: Traceback (most recent call last):
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\site\_basesite.py",
line 192, in __getattr__
method = getattr(self.family, attr)
AttributeError: 'Family' object has no attribute '_namespaces'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\tools\__init__.py",
line 726, in wrapper
return getattr(obj, cache_name)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\site\_basesite.py",
line 200, in __getattr__
raise AttributeError("{} instance has no attribute '{}'"
AttributeError: APISite instance has no attribute '_namespaces'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\data\api\_requests.py",
line 681, in _http_request
response = http.request(self.site, uri=uri,
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\comms\http.py",
line 233, in request
r = fetch(baseuri, headers=headers, **kwargs)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\comms\http.py",
line 399, in fetch
callback(response)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\comms\http.py",
line 272, in error_handling_callback
raise FatalServerError(str(response))
pywikibot.exceptions.FatalServerError: HTTPSConnectionPool(host='
he.wikisource.org', port=443): Max retries exceeded with url:
/w/api.php?action=query&meta=siteinfo%7Cuserinfo&siprop=namespaces%7Cnamespacealiases%7Cgeneral&continue=&uiprop=blockinfo%7Chasmsg&maxlag=5&format=json
(Caused by SSLError(SSLCertVerificationError(1, '[SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local
issuer certificate (_ssl.c:997)')))
Traceback (most recent call last):
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\site\_basesite.py",
line 192, in __getattr__
method = getattr(self.family, attr)
AttributeError: 'Family' object has no attribute '_namespaces'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\tools\__init__.py",
line 726, in wrapper
return getattr(obj, cache_name)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\site\_basesite.py",
line 200, in __getattr__
raise AttributeError("{} instance has no attribute '{}'"
AttributeError: APISite instance has no attribute '_namespaces'. Did you
mean: 'namespaces'?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pwb.py", line
39, in <module>
sys.exit(main())
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pwb.py", line
35, in main
runpy.run_path(str(path), run_name='__main__')
File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 289, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 86, in _run_code
exec(code, run_globals)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\scripts\wrapper.py",
line 516, in <module>
main()
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\scripts\wrapper.py",
line 500, in main
if not execute():
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\scripts\wrapper.py",
line 487, in execute
run_python_file(filename, script_args, module)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\scripts\wrapper.py",
line 147, in run_python_file
exec(compile(source, filename, 'exec', dont_inherit=True),
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\scripts\redirect.py",
line 742, in <module>
main()
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\scripts\redirect.py",
line 733, in main
if gen_factory.namespaces:
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\pagegenerators\_factory.py",
line 191, in namespaces
self.site.namespaces.resolve(self._namespaces))
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\tools\__init__.py",
line 728, in wrapper
val = fn(obj)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\site\_basesite.py",
line 246, in namespaces
return NamespacesDict(self._build_namespaces())
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\site\_apisite.py",
line 1063, in _build_namespaces
for nsdata in self.siteinfo.get('namespaces', cache=False).values():
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\site\_siteinfo.py",
line 304, in get
preloaded = self._get_general(key, expiry)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\site\_siteinfo.py",
line 242, in _get_general
default_info = self._get_siteinfo(props, expiry)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\site\_siteinfo.py",
line 167, in _get_siteinfo
data = request.submit()
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\data\api\_requests.py",
line 1236, in submit
self._data = super().submit()
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\data\api\_requests.py",
line 965, in submit
response, use_get = self._http_request(use_get, uri, body, headers,
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\data\api\_requests.py",
line 681, in _http_request
response = http.request(self.site, uri=uri,
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\comms\http.py",
line 233, in request
r = fetch(baseuri, headers=headers, **kwargs)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\comms\http.py",
line 399, in fetch
callback(response)
File
"C:\Users\IMOE001\Downloads\pywikibot-master\pywikibot-master\pywikibot\comms\http.py",
line 272, in error_handling_callback
raise FatalServerError(str(response))
pywikibot.exceptions.FatalServerError: HTTPSConnectionPool(host='
he.wikisource.org', port=443): Max retries exceeded with url:
/w/api.php?action=query&meta=siteinfo%7Cuserinfo&siprop=namespaces%7Cnamespacealiases%7Cgeneral&continue=&uiprop=blockinfo%7Chasmsg&maxlag=5&format=json
(Caused by SSLError(SSLCertVerificationError(1, '[SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local
issuer certificate (_ssl.c:997)')))
CRITICAL: Exiting due to uncaught exception <class
'pywikibot.exceptions.FatalServerError'>
בברכה,
ישראל קלר.