Now the add_text.py script is working. My best guess as to why is that I had
namespacealiases in cache that were incorrect and then the cache either expired or was
overwritten.
Why I think that:
My debugging led me to the _build_namespaces function in site.py. It does two api calls to
siteinfo.get. One to get the namespaces and one to get the namespacealiases. The second
call then iterates through the result set looking for ['*'] in the namespace
dictionary (returned from the siteinfo.get for namespace). It was here that the script
failed. It was looking for namespace 104 (which doesn't exist on my wiki and did not
get loaded into the siteinfo.get for namespace). For some unknown reason, it did get
loaded into the namespacealiases dict.
In trying to determine what namespaces and namespace aliases were actually installed on my
wiki, I queried api.php through my browser using this
format:
example.com/wiki/api.php?action=query&meta=siteinfo&siprop=namespac…
and then again changing siprop=namespaces to siprop=namespacealiases. Both of these
queries verified that neither namespace alias nor namespace 104 (and 105) exist on my
wiki.
After executing these two queries, I added a couple of pywikibot.output statements in
site.py to see if I could determine more info with what it is what retrieving in the
siteinfo function. It was then that the script worked correctly. My guess is that
executing the api.php query for namespacealiases refreshed the cache thereby removing the
alias to ns 104. It's a total guess, but all seems to be working now.
Thanks again for your help.Bud
From: "info(a)gno.de" <info(a)gno.de>
To: bloveall(a)yahoo.com; pywikibot(a)lists.wikimedia.org
Sent: Saturday, September 10, 2016 4:21 AM
Subject: Aw: [pywikibot] Newbie Q: Error running add_text script for first time
Could you geve us your family and site you worked on. And the result of pwb.py version
Thanks
xqt
----- Original Nachricht ----
Von: Bud <bloveall(a)yahoo.com>
An: "pywikibot(a)lists.wikimedia.org" <pywikibot(a)lists.wikimedia.org>
Datum: 10.09.2016 02:54
Betreff: [pywikibot] Newbie Q: Error running add_text script for first time
Hi All,
I'm new to Pywikibot (and Mediawiki as well). I've used the instructions on
[0] to install pywikibot on my Windows laptop accessing a Linux server. All
seems to be connected right (I'm successfully through step 9 and can login).
The next step is to run add_text to change text on some pages. Here I get an
error:
C:\Users\Owner\pywikibot>python pwb.py add_text.py -cat:Testing
-text:"Testing the add_text script using the Pywikibot user."
-except:"\{\{([Tt]emplate:|)[Dd]ocumentation [Ss]ubpage" -upTraceback (most
recent call last): File "pwb.py", line 270, in <module> if not
main():
File "pwb.py", line 264, in main run_python_file(filename, [filename] +
args, argvu, file_package) File "pwb.py", line 109, in run_python_file
main_mod.__dict__) File ".\scripts\add_text.py", line 358, in <module>
main() File ".\scripts\add_text.py", line 338, in main
genFactory.handleArg(arg) File
"C:\Users\Owner\pywikibot\pywikibot\pagegenerators.py", line 589, in
handleArg gen = self.getCategoryGen(arg,
gen_func=CategorizedPageGenerator) File
"C:\Users\Owner\pywikibot\pywikibot\pagegenerators.py", line 420, in
getCategoryGen if prefix not in self.site.namespaces[14]: File
"C:\Users\Owner\pywikibot\pywikibot\site.py", line 806, in namespaces
self._namespaces = _NamespacesDict(self._build_namespaces()) File
"C:\Users\Owner\pywikibot\pywikibot\site.py", line 2185, in
_build_namespaces if item['*'] not in _namespaces[ns]:KeyError: 104<class
'KeyError'>CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c
to abort
I've verified the Category name exists and is spelled correctly. Not sure
what to try next to figure this out. Any help is appreciated.
Thanks,Bud Loveall
P.S. Also, is there a way to search the archives of the mail list? I'm
guessing this has been answered before.
--------------------------------
_______________________________________________
pywikibot mailing list
pywikibot(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot