Hello,
In one of my scripts, I'm editing a few pages and one of them requires sysop privileges. Before OAuth, I was able to logout, then login as sysop and .save() the page ( https://gist.github.com/alkamid/639abbb05ff8e0d2842d0c9dbda1e2d0#file-addlan...). Now I'm trying to implement the same with OAuth. Saving the protected page works fine, but later in the script, when saving another unprotected page (L190), I get the following error:
Traceback (most recent call last): File "/home/adam/wikt/pywikibot/core/pywikibot/page.py", line 1219, in _save watch=watch, bot=botflag, **kwargs) File "/home/adam/wikt/pywikibot/core/pywikibot/site.py", line 1325, in callee self.login(False) File "/home/adam/wikt/pywikibot/core/pywikibot/site.py", line 2077, in login 'right': self._username[sysop]}) pywikibot.exceptions.NoUsername: Logged in on wiktionary:pl via OAuth as Alkamid, but expect as AlkamidBot
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "addLang.py", line 197, in <module> main() File "addLang.py", line 190, in main page8.save(summary="Dodanie języka %s" % zjezyka) File "/home/adam/wikt/pywikibot/core/pywikibot/tools/__init__.py", line 1447, in wrapper return obj(*__args, **__kw) File "/home/adam/wikt/pywikibot/core/pywikibot/page.py", line 1208, in save cc=apply_cosmetic_changes, quiet=quiet, **kwargs) File "/home/adam/wikt/pywikibot/core/pywikibot/page.py", line 1234, in _save raise pywikibot.OtherPageSaveError(self, err) pywikibot.exceptions.OtherPageSaveError: Edit to page [[Moduł:statystyka/dane]] failed: Logged in on wiktionary:pl via OAuth as Alkamid, but expect as AlkamidBot <class 'pywikibot.exceptions.OtherPageSaveError'> CRITICAL: Closing network session.
How to do this properly? My user-config.py:
usernames['wiktionary']['pl'] = u'AlkamidBot' sysopnames['wiktionary']['pl'] = u'Alkamid' usernames['commons']['commons'] = 'Alkamid'
authenticate['pl.wiktionary.org'] = ('a', 'b', 'c', 'd') #credentials deleted authenticate['pl.wiktionary.org'] = ('e', 'f, 'g', 'h') #credentials deleted
Best wishes Alkamid
Hi Alkamid,
I'm not expert on this, but it looks like there is no way to do that with OAuth yet. I think Pywikibot currently supports OAuth only when you use a single account. The support of the two-account workflow has been discussed in the Phabricator task T142303. [1]
A workaround might be to create separate Pywikbot environments for the two accounts. You can use the -dir parameter to override the default "~/.pywikibot/" directory.
[1] https://phabricator.wikimedia.org/T142303
-Yusuke
On Thu, Oct 27, 2016 at 2:45 PM, Adam Klimont adamkli@gmail.com wrote:
Hello,
In one of my scripts, I'm editing a few pages and one of them requires sysop privileges. Before OAuth, I was able to logout, then login as sysop and .save() the page (https://gist.github.com/alkamid/639abbb05ff8e0d2842d0c9dbda1e2d0#file-addlan...). Now I'm trying to implement the same with OAuth. Saving the protected page works fine, but later in the script, when saving another unprotected page (L190), I get the following error:
Traceback (most recent call last): File "/home/adam/wikt/pywikibot/core/pywikibot/page.py", line 1219, in _save watch=watch, bot=botflag, **kwargs) File "/home/adam/wikt/pywikibot/core/pywikibot/site.py", line 1325, in callee self.login(False) File "/home/adam/wikt/pywikibot/core/pywikibot/site.py", line 2077, in login 'right': self._username[sysop]}) pywikibot.exceptions.NoUsername: Logged in on wiktionary:pl via OAuth as Alkamid, but expect as AlkamidBot
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "addLang.py", line 197, in <module> main() File "addLang.py", line 190, in main page8.save(summary="Dodanie języka %s" % zjezyka) File "/home/adam/wikt/pywikibot/core/pywikibot/tools/__init__.py", line 1447, in wrapper return obj(*__args, **__kw) File "/home/adam/wikt/pywikibot/core/pywikibot/page.py", line 1208, in save cc=apply_cosmetic_changes, quiet=quiet, **kwargs) File "/home/adam/wikt/pywikibot/core/pywikibot/page.py", line 1234, in _save raise pywikibot.OtherPageSaveError(self, err) pywikibot.exceptions.OtherPageSaveError: Edit to page [[Moduł:statystyka/dane]] failed: Logged in on wiktionary:pl via OAuth as Alkamid, but expect as AlkamidBot <class 'pywikibot.exceptions.OtherPageSaveError'> CRITICAL: Closing network session.
How to do this properly? My user-config.py:
usernames['wiktionary']['pl'] = u'AlkamidBot' sysopnames['wiktionary']['pl'] = u'Alkamid' usernames['commons']['commons'] = 'Alkamid'
authenticate['pl.wiktionary.org'] = ('a', 'b', 'c', 'd') #credentials deleted authenticate['pl.wiktionary.org'] = ('e', 'f, 'g', 'h') #credentials deleted
Best wishes Alkamid
pywikibot mailing list pywikibot@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot