Hi all,
I'm building a small pywikibot tool[1] which is designed to be installed via pip (and in turn installs Pywikibot via pip).
The tool uses the page.touch() function which is where I get a pywikibot.i18n.TranslationError when I run it.
page.touch() gets it's edit summary from i18n.twtranslate(self.site, 'pywikibot-touch') which in turn is defined in /scripts/i18n/pywikibot/. Unless I'm confused the Error occurs because the pip distribution does not include the /scripts folder or the i18n submodule.
So my first question is am I just doing something obviously wrong and the i18n submodule should have been available over pip as well?
If it's not just me then would it not make sense to have any i18n files necessary to the Pywikibot *library* to also be distributed via the same pip package? (i18n for scripts is another issue since for scripts you cannot use pip).
Cheers, André / Lokal_Profil
[1] https://github.com/lokal-profil/pywikibot-sdc André Costa | Chief Operating Officer, Wikimedia Sverige | Andre.Costa@wikimedia.se | +46 (0)733-964574
Stöd fri kunskap, bli medlem i Wikimedia Sverige. Läs mer på blimedlem.wikimedia.se
------ sent from my mobile, all typos are due to autocorrect ;)
Hi André,
Looking at https://github.com/wikimedia/pywikibot/blob/master/pywikibot/i18n.py#L6, it sounds to me like in principe the core Pywikibot code should never call i18n.*.
There are currently a few places where this _does_ happen:
* pagegenerators.py, which uses a fallback in case i18n data is not available: https://github.com/wikimedia/pywikibot/blob/master/pywikibot/pagegenerators.... -- so these are OK. * page/__init__.py calls twtranslate in: 1) the cosmetic changes fallback. This one is a little difficult to fix -- maybe it should fall back to a hardcoded English string in case i18n is not available? 2) the touch method. The method should probably require summary to be passed as part of the method signature. The corresponding script scripts/touch.py / scripts/newitem.py can then do the i18n lookup. ... in principle, we could also just use a hardcoded summary and not bother translating. After all, touch is supposed to *not modify* the text and therefore the edit summary _shouldn't be visible_.*..*
Indeed the other approach would be to bundle a subset of i18n data with the framework (these are all in scripts/i18n/pywikibot). However the loading setup is a little bit complex due to the data being json files that could be in a (zipped) Python package...
Cheers, Merlijn
On Thu, 25 Feb 2021 at 14:30, André Costa lokal.profil@gmail.com wrote:
Hi all,
I'm building a small pywikibot tool[1] which is designed to be installed via pip (and in turn installs Pywikibot via pip).
The tool uses the page.touch() function which is where I get a pywikibot.i18n.TranslationError when I run it.
page.touch() gets it's edit summary from i18n.twtranslate(self.site, 'pywikibot-touch') which in turn is defined in /scripts/i18n/pywikibot/. Unless I'm confused the Error occurs because the pip distribution does not include the /scripts folder or the i18n submodule.
So my first question is am I just doing something obviously wrong and the i18n submodule should have been available over pip as well?
If it's not just me then would it not make sense to have any i18n files necessary to the Pywikibot *library* to also be distributed via the same pip package? (i18n for scripts is another issue since for scripts you cannot use pip).
Cheers, André / Lokal_Profil
[1] https://github.com/lokal-profil/pywikibot-sdc André Costa | Chief Operating Officer, Wikimedia Sverige | Andre.Costa@wikimedia.se | +46 (0)733-964574
Stöd fri kunskap, bli medlem i Wikimedia Sverige. Läs mer på blimedlem.wikimedia.se
sent from my mobile, all typos are due to autocorrect ;) _______________________________________________ pywikibot mailing list pywikibot@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot
I opened T275981 for it.
Best xqt
Am 27.02.2021 um 14:27 schrieb Merlijn van Deen (valhallasw) valhallasw@arctus.nl:
Hi André,
Looking at https://github.com/wikimedia/pywikibot/blob/master/pywikibot/i18n.py#L6, it sounds to me like in principe the core Pywikibot code should never call i18n.*.
There are currently a few places where this _does_ happen:
- pagegenerators.py, which uses a fallback in case i18n data is not available: https://github.com/wikimedia/pywikibot/blob/master/pywikibot/pagegenerators.... -- so these are OK.
- page/__init__.py calls twtranslate in:
- the cosmetic changes fallback. This one is a little difficult to fix -- maybe it should fall back to a hardcoded English string in case i18n is not available?
- the touch method. The method should probably require summary to be passed as part of the method signature. The corresponding script scripts/touch.py / scripts/newitem.py can then do the i18n lookup. ... in principle, we could also just use a hardcoded summary and not bother translating. After all, touch is supposed to not modify the text and therefore the edit summary _shouldn't be visible_...
Indeed the other approach would be to bundle a subset of i18n data with the framework (these are all in scripts/i18n/pywikibot). However the loading setup is a little bit complex due to the data being json files that could be in a (zipped) Python package...
Cheers, Merlijn
On Thu, 25 Feb 2021 at 14:30, André Costa lokal.profil@gmail.com wrote: Hi all,
I'm building a small pywikibot tool[1] which is designed to be installed via pip (and in turn installs Pywikibot via pip).
The tool uses the page.touch() function which is where I get a pywikibot.i18n.TranslationError when I run it.
page.touch() gets it's edit summary from i18n.twtranslate(self.site, 'pywikibot-touch') which in turn is defined in /scripts/i18n/pywikibot/. Unless I'm confused the Error occurs because the pip distribution does not include the /scripts folder or the i18n submodule.
So my first question is am I just doing something obviously wrong and the i18n submodule should have been available over pip as well?
If it's not just me then would it not make sense to have any i18n files necessary to the Pywikibot library to also be distributed via the same pip package? (i18n for scripts is another issue since for scripts you cannot use pip).
Cheers, André / Lokal_Profil
[1] https://github.com/lokal-profil/pywikibot-sdc André Costa | Chief Operating Officer, Wikimedia Sverige | Andre.Costa@wikimedia.se | +46 (0)733-964574
Stöd fri kunskap, bli medlem i Wikimedia Sverige. Läs mer på blimedlem.wikimedia.se
sent from my mobile, all typos are due to autocorrect ;) _______________________________________________ pywikibot mailing list pywikibot@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot
pywikibot mailing list pywikibot@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot
Solution submitted. Will upload it to pypi shortly. Thanks to Merlijn for review.
Best xqt
Am 28.02.2021 um 12:18 schrieb info@gno.de:
I opened T275981 for it.
Best xqt
Am 27.02.2021 um 14:27 schrieb Merlijn van Deen (valhallasw) valhallasw@arctus.nl:
Hi André,
Looking at https://github.com/wikimedia/pywikibot/blob/master/pywikibot/i18n.py#L6, it sounds to me like in principe the core Pywikibot code should never call i18n.*.
There are currently a few places where this _does_ happen:
- pagegenerators.py, which uses a fallback in case i18n data is not available: https://github.com/wikimedia/pywikibot/blob/master/pywikibot/pagegenerators.... -- so these are OK.
- page/__init__.py calls twtranslate in:
- the cosmetic changes fallback. This one is a little difficult to fix -- maybe it should fall back to a hardcoded English string in case i18n is not available?
- the touch method. The method should probably require summary to be passed as part of the method signature. The corresponding script scripts/touch.py / scripts/newitem.py can then do the i18n lookup. ... in principle, we could also just use a hardcoded summary and not bother translating. After all, touch is supposed to not modify the text and therefore the edit summary _shouldn't be visible_...
Indeed the other approach would be to bundle a subset of i18n data with the framework (these are all in scripts/i18n/pywikibot). However the loading setup is a little bit complex due to the data being json files that could be in a (zipped) Python package...
Cheers, Merlijn
On Thu, 25 Feb 2021 at 14:30, André Costa lokal.profil@gmail.com wrote: Hi all,
I'm building a small pywikibot tool[1] which is designed to be installed via pip (and in turn installs Pywikibot via pip).
The tool uses the page.touch() function which is where I get a pywikibot.i18n.TranslationError when I run it.
page.touch() gets it's edit summary from i18n.twtranslate(self.site, 'pywikibot-touch') which in turn is defined in /scripts/i18n/pywikibot/. Unless I'm confused the Error occurs because the pip distribution does not include the /scripts folder or the i18n submodule.
So my first question is am I just doing something obviously wrong and the i18n submodule should have been available over pip as well?
If it's not just me then would it not make sense to have any i18n files necessary to the Pywikibot library to also be distributed via the same pip package? (i18n for scripts is another issue since for scripts you cannot use pip).
Cheers, André / Lokal_Profil
[1] https://github.com/lokal-profil/pywikibot-sdc André Costa | Chief Operating Officer, Wikimedia Sverige | Andre.Costa@wikimedia.se | +46 (0)733-964574
Stöd fri kunskap, bli medlem i Wikimedia Sverige. Läs mer på blimedlem.wikimedia.se
sent from my mobile, all typos are due to autocorrect ;) _______________________________________________ pywikibot mailing list pywikibot@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot
pywikibot mailing list pywikibot@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot
Thanks for the quick fix!
------ sent from my mobile, all typos are due to autocorrect ;)
On Sun, 28 Feb 2021, 14:53 , info@gno.de wrote:
Solution submitted. Will upload it to pypi shortly. Thanks to Merlijn for review.
Best xqt
Am 28.02.2021 um 12:18 schrieb info@gno.de:
I opened T275981 for it.
Best xqt
Am 27.02.2021 um 14:27 schrieb Merlijn van Deen (valhallasw) < valhallasw@arctus.nl>:
Hi André,
Looking at https://github.com/wikimedia/pywikibot/blob/master/pywikibot/i18n.py#L6, it sounds to me like in principe the core Pywikibot code should never call i18n.*.
There are currently a few places where this _does_ happen:
- pagegenerators.py, which uses a fallback in case i18n data is not
available: https://github.com/wikimedia/pywikibot/blob/master/pywikibot/pagegenerators.... -- so these are OK.
- page/__init__.py calls twtranslate in:
- the cosmetic changes fallback. This one is a little difficult to fix
-- maybe it should fall back to a hardcoded English string in case i18n is not available? 2) the touch method. The method should probably require summary to be passed as part of the method signature. The corresponding script scripts/touch.py / scripts/newitem.py can then do the i18n lookup. ... in principle, we could also just use a hardcoded summary and not bother translating. After all, touch is supposed to *not modify* the text and therefore the edit summary _shouldn't be visible_.*..*
Indeed the other approach would be to bundle a subset of i18n data with the framework (these are all in scripts/i18n/pywikibot). However the loading setup is a little bit complex due to the data being json files that could be in a (zipped) Python package...
Cheers, Merlijn
On Thu, 25 Feb 2021 at 14:30, André Costa lokal.profil@gmail.com wrote:
Hi all,
I'm building a small pywikibot tool[1] which is designed to be installed via pip (and in turn installs Pywikibot via pip).
The tool uses the page.touch() function which is where I get a pywikibot.i18n.TranslationError when I run it.
page.touch() gets it's edit summary from i18n.twtranslate(self.site, 'pywikibot-touch') which in turn is defined in /scripts/i18n/pywikibot/. Unless I'm confused the Error occurs because the pip distribution does not include the /scripts folder or the i18n submodule.
So my first question is am I just doing something obviously wrong and the i18n submodule should have been available over pip as well?
If it's not just me then would it not make sense to have any i18n files necessary to the Pywikibot *library* to also be distributed via the same pip package? (i18n for scripts is another issue since for scripts you cannot use pip).
Cheers, André / Lokal_Profil
[1] https://github.com/lokal-profil/pywikibot-sdc André Costa | Chief Operating Officer, Wikimedia Sverige | Andre.Costa@wikimedia.se | +46 (0)733-964574
Stöd fri kunskap, bli medlem i Wikimedia Sverige. Läs mer på blimedlem.wikimedia.se
sent from my mobile, all typos are due to autocorrect ;) _______________________________________________ pywikibot mailing list pywikibot@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot
pywikibot mailing list pywikibot@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot
pywikibot mailing list pywikibot@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org'] = (....*****.....)
the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
I'm a total newbie at pywikibot, but let me address the general issue of putting credentials in config files.
Be very wary of how you store credentials. You should make sure they're in a file which is read-protected, and not in source control. Otherwise the entire world will have access to your secret credentials.
On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote:
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org'] = (....*****.....) the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
No worries,
I do software dev for a living. It's all local and no one is checking in credentials. But that wasn't really the question here.
On 05.09.22 17:21, Roy Smith wrote:
I'm a total newbie at pywikibot, but let me address the general issue of putting credentials in config files.
Be very wary of how you store credentials. You should make sure they're in a file which is read-protected, and not in source control. Otherwise the entire world will have access to your secret credentials.
On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote:
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org http://de.wikisource.org'] = (....*****.....)
the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list --pywikibot@lists.wikimedia.org To unsubscribe send an email topywikibot-leave@lists.wikimedia.org
I don't know but many years ago I ran an admin bot on a non-WMF wiki. A separate sysopnames variable was used to specify a user with admin credentials. Sysopnames was removed from pywikibot and whereas I've never used it, the theory is that now you have only a single bot user as defined in usernames. Pywikibot uses that user for normal actions and for admin actions. If admin privilege is needed, I think it first checks if the user has the required privilege. Some info on what I'm saying is at https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html
So if you had usernames['wikisource']['de'] = 'Example'
where Example has the bot and sysop flags, it should work. Try a simple script to delete a junk user subpage and report what happens. I don't know if it's possible with MediaWiki, but it's conceivable that pywikibot does not give itself admin credentials unless required (which might explain your debug results).
Johnuniq
On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer ersotech@posteo.de wrote:
No worries,
I do software dev for a living. It's all local and no one is checking in credentials. But that wasn't really the question here.
On 05.09.22 17:21, Roy Smith wrote:
I'm a total newbie at pywikibot, but let me address the general issue of putting credentials in config files.
Be very wary of how you store credentials. You should make sure they're in a file which is read-protected, and not in source control. Otherwise the entire world will have access to your secret credentials.
On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote:
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org'] = (....*****.....)
the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
This experiment was the initial reason for my post. I have one bot configured and I tried to protect some pages. This is stack trace from this experiment:
File "/home/esommer/workspace/WS_THEbotIT/service/protect.py", line 47, in task lemma.protect(reason="Schutz fertiger Seiten", File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py", line 1998, in protect self.site.protect(self, protections, reason, **kwargs) File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/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 "protect"
The User "None" seems concerning. Is there a chance I screwed up the scopes when I generated the OAuth token at https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oa...
Cheers Erik
On 06.09.22 07:42, Johnuniq wrote:
I don't know but many years ago I ran an admin bot on a non-WMF wiki. A separate sysopnames variable was used to specify a user with admin credentials. Sysopnames was removed from pywikibot and whereas I've never used it, the theory is that now you have only a single bot user as defined in usernames. Pywikibot uses that user for normal actions and for admin actions. If admin privilege is needed, I think it first checks if the user has the required privilege. Some info on what I'm saying is at https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html
So if you had usernames['wikisource']['de'] = 'Example'
where Example has the bot and sysop flags, it should work. Try a simple script to delete a junk user subpage and report what happens. I don't know if it's possible with MediaWiki, but it's conceivable that pywikibot does not give itself admin credentials unless required (which might explain your debug results).
Johnuniq
On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer ersotech@posteo.de wrote:
No worries,
I do software dev for a living. It's all local and no one is checking in credentials. But that wasn't really the question here.
On 05.09.22 17:21, Roy Smith wrote:
I'm a total newbie at pywikibot, but let me address the general issue of putting credentials in config files.
Be very wary of how you store credentials. You should make sure they're in a file which is read-protected, and not in source control. Otherwise the entire world will have access to your secret credentials.
On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote:
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org'] = (....*****.....)
the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
I upgraded all my pip modules yesterday, including pywikibot. Your line numbers are 18 lines different from mine in _pages.py so you might upgrade although that is unlikely to help.
Browsing around the source shows that @need_right('protect') is in site/_apisite.py and is responsible for the message: 'User "None" does not have required user right "protect"'.
site/_basesite.py returns None if self.logged_in() tests as false. My guess is that you are not logged in and it looks like it would be easy to stuff up Special:OAuthConsumerRegistration. I would try manually entering lines of code into python to mimic a simple bot start-up, then see if site.user() shows the bot name.
On Tue, Sep 6, 2022 at 4:04 PM Erik Sommer ersotech@posteo.de wrote:
This experiment was the initial reason for my post. I have one bot configured and I tried to protect some pages. This is stack trace from this experiment:
File "/home/esommer/workspace/WS_THEbotIT/service/protect.py", line 47, in task lemma.protect(reason="Schutz fertiger Seiten", File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py", line 1998, in protect self.site.protect(self, protections, reason, **kwargs) File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/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 "protect"
The User "None" seems concerning. Is there a chance I screwed up the scopes when I generated the OAuth token at https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oa...
Cheers Erik
On 06.09.22 07:42, Johnuniq wrote:
I don't know but many years ago I ran an admin bot on a non-WMF wiki. A separate sysopnames variable was used to specify a user with admin credentials. Sysopnames was removed from pywikibot and whereas I've never used it, the theory is that now you have only a single bot user as defined in usernames. Pywikibot uses that user for normal actions and for admin actions. If admin privilege is needed, I think it first checks if the user has the required privilege. Some info on what I'm saying is at https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html
So if you had usernames['wikisource']['de'] = 'Example'
where Example has the bot and sysop flags, it should work. Try a simple script to delete a junk user subpage and report what happens. I don't know if it's possible with MediaWiki, but it's conceivable that pywikibot does not give itself admin credentials unless required (which might explain your debug results).
Johnuniq
On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer ersotech@posteo.de wrote:
No worries,
I do software dev for a living. It's all local and no one is checking in credentials. But that wasn't really the question here.
On 05.09.22 17:21, Roy Smith wrote:
I'm a total newbie at pywikibot, but let me address the general issue of putting credentials in config files.
Be very wary of how you store credentials. You should make sure they're in a file which is read-protected, and not in source control. Otherwise the entire world will have access to your secret credentials.
On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote:
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org'] = (....*****.....)
the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
Thanks Johnuniq and also xqt for the good hints,
at last I found my mistake. I'm operating two bot accounts at the moment. One does all the heavy lifting, but hasn't any sysop rights. The other one is for sysop actions only (was a wish by the community).
The solution provided by piwikibot is to use the env variable PYWIKIBOT_DIR. I did that to point to the alternative user-config. But I made a mistake and I kid you not: A leading whitespace infront of the variable :facepalm: ... therefor the framework fall back to the normal pywikibot config path and loaded the config of the non-sysop bot :-(.
Thanks to all for the help
Cheers Erik
On 06.09.22 11:38, Johnuniq wrote:
I upgraded all my pip modules yesterday, including pywikibot. Your line numbers are 18 lines different from mine in _pages.py so you might upgrade although that is unlikely to help.
Browsing around the source shows that @need_right('protect') is in site/_apisite.py and is responsible for the message: 'User "None" does not have required user right "protect"'.
site/_basesite.py returns None if self.logged_in() tests as false. My guess is that you are not logged in and it looks like it would be easy to stuff up Special:OAuthConsumerRegistration. I would try manually entering lines of code into python to mimic a simple bot start-up, then see if site.user() shows the bot name.
On Tue, Sep 6, 2022 at 4:04 PM Erik Sommer ersotech@posteo.de wrote:
This experiment was the initial reason for my post. I have one bot configured and I tried to protect some pages. This is stack trace from this experiment:
File "/home/esommer/workspace/WS_THEbotIT/service/protect.py", line
47, in task lemma.protect(reason="Schutz fertiger Seiten", File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py", line 1998, in protect self.site.protect(self, protections, reason, **kwargs) File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/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 "protect"
The User "None" seems concerning. Is there a chance I screwed up the scopes when I generated the OAuth token at https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oa...
Cheers Erik
On 06.09.22 07:42, Johnuniq wrote:
I don't know but many years ago I ran an admin bot on a non-WMF wiki. A separate sysopnames variable was used to specify a user with admin credentials. Sysopnames was removed from pywikibot and whereas I've never used it, the theory is that now you have only a single bot user as defined in usernames. Pywikibot uses that user for normal actions and for admin actions. If admin privilege is needed, I think it first checks if the user has the required privilege. Some info on what I'm saying is at https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html
So if you had usernames['wikisource']['de'] = 'Example'
where Example has the bot and sysop flags, it should work. Try a simple script to delete a junk user subpage and report what happens. I don't know if it's possible with MediaWiki, but it's conceivable that pywikibot does not give itself admin credentials unless required (which might explain your debug results).
Johnuniq
On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer ersotech@posteo.de wrote:
No worries,
I do software dev for a living. It's all local and no one is checking in credentials. But that wasn't really the question here.
On 05.09.22 17:21, Roy Smith wrote:
I'm a total newbie at pywikibot, but let me address the general issue of putting credentials in config files.
Be very wary of how you store credentials. You should make sure they're in a file which is read-protected, and not in source control. Otherwise the entire world will have access to your secret credentials.
On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote:
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org'] = (....*****.....)
the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
Also in addition. The scoping of the OAuth token works perfectly. The sysop bot has only the protect right.
On 07.09.22 09:14, Erik Sommer wrote:
Thanks Johnuniq and also xqt for the good hints,
at last I found my mistake. I'm operating two bot accounts at the moment. One does all the heavy lifting, but hasn't any sysop rights. The other one is for sysop actions only (was a wish by the community).
The solution provided by piwikibot is to use the env variable PYWIKIBOT_DIR. I did that to point to the alternative user-config. But I made a mistake and I kid you not: A leading whitespace infront of the variable :facepalm: ... therefor the framework fall back to the normal pywikibot config path and loaded the config of the non-sysop bot :-(.
Thanks to all for the help
Cheers Erik
On 06.09.22 11:38, Johnuniq wrote:
I upgraded all my pip modules yesterday, including pywikibot. Your line numbers are 18 lines different from mine in _pages.py so you might upgrade although that is unlikely to help.
Browsing around the source shows that @need_right('protect') is in site/_apisite.py and is responsible for the message: 'User "None" does not have required user right "protect"'.
site/_basesite.py returns None if self.logged_in() tests as false. My guess is that you are not logged in and it looks like it would be easy to stuff up Special:OAuthConsumerRegistration. I would try manually entering lines of code into python to mimic a simple bot start-up, then see if site.user() shows the bot name.
On Tue, Sep 6, 2022 at 4:04 PM Erik Sommer ersotech@posteo.de wrote:
This experiment was the initial reason for my post. I have one bot configured and I tried to protect some pages. This is stack trace from this experiment:
File "/home/esommer/workspace/WS_THEbotIT/service/protect.py", line 47, in task lemma.protect(reason="Schutz fertiger Seiten", File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py",
line 1998, in protect self.site.protect(self, protections, reason, **kwargs) File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/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 "protect"
The User "None" seems concerning. Is there a chance I screwed up the scopes when I generated the OAuth token at https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oa...
Cheers Erik
On 06.09.22 07:42, Johnuniq wrote:
I don't know but many years ago I ran an admin bot on a non-WMF wiki. A separate sysopnames variable was used to specify a user with admin credentials. Sysopnames was removed from pywikibot and whereas I've never used it, the theory is that now you have only a single bot user as defined in usernames. Pywikibot uses that user for normal actions and for admin actions. If admin privilege is needed, I think it first checks if the user has the required privilege. Some info on what I'm saying is at https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html
So if you had usernames['wikisource']['de'] = 'Example'
where Example has the bot and sysop flags, it should work. Try a simple script to delete a junk user subpage and report what happens. I don't know if it's possible with MediaWiki, but it's conceivable that pywikibot does not give itself admin credentials unless required (which might explain your debug results).
Johnuniq
On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer ersotech@posteo.de wrote:
No worries,
I do software dev for a living. It's all local and no one is checking in credentials. But that wasn't really the question here.
On 05.09.22 17:21, Roy Smith wrote:
I'm a total newbie at pywikibot, but let me address the general issue of putting credentials in config files.
Be very wary of how you store credentials. You should make sure they're in a file which is read-protected, and not in source control. Otherwise the entire world will have access to your secret credentials.
On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote:
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org'] = (....*****.....)
the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
Good work!
use the env variable PYWIKIBOT_DIR
Oh. At one time I was using two accounts at one site and I used a script to copy the wanted user-config.py to the pywikibot directory. If I need that again, I'll try to remember to use the env variable.
On Wed, Sep 7, 2022 at 4:15 PM Erik Sommer ersotech@posteo.de wrote:
Thanks Johnuniq and also xqt for the good hints,
at last I found my mistake. I'm operating two bot accounts at the moment. One does all the heavy lifting, but hasn't any sysop rights. The other one is for sysop actions only (was a wish by the community).
The solution provided by piwikibot is to use the env variable PYWIKIBOT_DIR. I did that to point to the alternative user-config. But I made a mistake and I kid you not: A leading whitespace infront of the variable :facepalm: ... therefor the framework fall back to the normal pywikibot config path and loaded the config of the non-sysop bot :-(.
Thanks to all for the help
Cheers Erik
On 06.09.22 11:38, Johnuniq wrote:
I upgraded all my pip modules yesterday, including pywikibot. Your line numbers are 18 lines different from mine in _pages.py so you might upgrade although that is unlikely to help.
Browsing around the source shows that @need_right('protect') is in site/_apisite.py and is responsible for the message: 'User "None" does not have required user right "protect"'.
site/_basesite.py returns None if self.logged_in() tests as false. My guess is that you are not logged in and it looks like it would be easy to stuff up Special:OAuthConsumerRegistration. I would try manually entering lines of code into python to mimic a simple bot start-up, then see if site.user() shows the bot name.
On Tue, Sep 6, 2022 at 4:04 PM Erik Sommer ersotech@posteo.de wrote:
This experiment was the initial reason for my post. I have one bot configured and I tried to protect some pages. This is stack trace from this experiment:
File "/home/esommer/workspace/WS_THEbotIT/service/protect.py", line
47, in task lemma.protect(reason="Schutz fertiger Seiten", File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py", line 1998, in protect self.site.protect(self, protections, reason, **kwargs) File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/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 "protect"
The User "None" seems concerning. Is there a chance I screwed up the scopes when I generated the OAuth token at https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oa...
Cheers Erik
On 06.09.22 07:42, Johnuniq wrote:
I don't know but many years ago I ran an admin bot on a non-WMF wiki. A separate sysopnames variable was used to specify a user with admin credentials. Sysopnames was removed from pywikibot and whereas I've never used it, the theory is that now you have only a single bot user as defined in usernames. Pywikibot uses that user for normal actions and for admin actions. If admin privilege is needed, I think it first checks if the user has the required privilege. Some info on what I'm saying is at https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html
So if you had usernames['wikisource']['de'] = 'Example'
where Example has the bot and sysop flags, it should work. Try a simple script to delete a junk user subpage and report what happens. I don't know if it's possible with MediaWiki, but it's conceivable that pywikibot does not give itself admin credentials unless required (which might explain your debug results).
Johnuniq
On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer ersotech@posteo.de wrote:
No worries,
I do software dev for a living. It's all local and no one is checking in credentials. But that wasn't really the question here.
On 05.09.22 17:21, Roy Smith wrote:
I'm a total newbie at pywikibot, but let me address the general issue of putting credentials in config files.
Be very wary of how you store credentials. You should make sure they're in a file which is read-protected, and not in source control. Otherwise the entire world will have access to your secret credentials.
On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote:
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org'] = (....*****.....)
the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
how You use different configs in the same script?
PYWIKIBOT_DIR points to one config.
It used to be possible to specify normal and admin account in the same user-config.py
As I I understand it is not the case anymore.
What I need is a possibility to edit with a normal bot account and, for example if the page is empty delete it using bot admin account. Is this possible within one config?
PS: yes, I do have 2 bot accounts: one a normal bot and another with admin rights
masti
On 07.09.2022 08:14, Erik Sommer wrote:
Thanks Johnuniq and also xqt for the good hints,
at last I found my mistake. I'm operating two bot accounts at the moment. One does all the heavy lifting, but hasn't any sysop rights. The other one is for sysop actions only (was a wish by the community).
The solution provided by piwikibot is to use the env variable PYWIKIBOT_DIR. I did that to point to the alternative user-config. But I made a mistake and I kid you not: A leading whitespace infront of the variable :facepalm: ... therefor the framework fall back to the normal pywikibot config path and loaded the config of the non-sysop bot :-(.
Thanks to all for the help
Cheers Erik
On 06.09.22 11:38, Johnuniq wrote:
I upgraded all my pip modules yesterday, including pywikibot. Your line numbers are 18 lines different from mine in _pages.py so you might upgrade although that is unlikely to help.
Browsing around the source shows that @need_right('protect') is in site/_apisite.py and is responsible for the message: 'User "None" does not have required user right "protect"'.
site/_basesite.py returns None if self.logged_in() tests as false. My guess is that you are not logged in and it looks like it would be easy to stuff up Special:OAuthConsumerRegistration. I would try manually entering lines of code into python to mimic a simple bot start-up, then see if site.user() shows the bot name.
On Tue, Sep 6, 2022 at 4:04 PM Erik Sommer ersotech@posteo.de wrote:
This experiment was the initial reason for my post. I have one bot configured and I tried to protect some pages. This is stack trace from this experiment:
File "/home/esommer/workspace/WS_THEbotIT/service/protect.py", line 47, in task lemma.protect(reason="Schutz fertiger Seiten", File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py",
line 1998, in protect self.site.protect(self, protections, reason, **kwargs) File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/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 "protect"
The User "None" seems concerning. Is there a chance I screwed up the scopes when I generated the OAuth token at https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oa...
Cheers Erik
On 06.09.22 07:42, Johnuniq wrote:
I don't know but many years ago I ran an admin bot on a non-WMF wiki. A separate sysopnames variable was used to specify a user with admin credentials. Sysopnames was removed from pywikibot and whereas I've never used it, the theory is that now you have only a single bot user as defined in usernames. Pywikibot uses that user for normal actions and for admin actions. If admin privilege is needed, I think it first checks if the user has the required privilege. Some info on what I'm saying is at https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html
So if you had usernames['wikisource']['de'] = 'Example'
where Example has the bot and sysop flags, it should work. Try a simple script to delete a junk user subpage and report what happens. I don't know if it's possible with MediaWiki, but it's conceivable that pywikibot does not give itself admin credentials unless required (which might explain your debug results).
Johnuniq
On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer ersotech@posteo.de wrote:
No worries,
I do software dev for a living. It's all local and no one is checking in credentials. But that wasn't really the question here.
On 05.09.22 17:21, Roy Smith wrote:
I'm a total newbie at pywikibot, but let me address the general issue of putting credentials in config files.
Be very wary of how you store credentials. You should make sure they're in a file which is read-protected, and not in source control. Otherwise the entire world will have access to your secret credentials.
On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote:
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org'] = (....*****.....)
the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
Now I don't use two accounts in the same script invocation. But I use a collection of scripts (self written, not part of pywikibot) and use them with different bot accounts. How to use different accounts in the same invocation, that I don't know. Can someone other help, because I see it similar as masti, this seems not possible anymore after the deprecation of sysopnames.
Erik
On 07.09.22 13:42, mastigm wrote:
how You use different configs in the same script?
PYWIKIBOT_DIR points to one config.
It used to be possible to specify normal and admin account in the same user-config.py
As I I understand it is not the case anymore.
What I need is a possibility to edit with a normal bot account and, for example if the page is empty delete it using bot admin account. Is this possible within one config?
PS: yes, I do have 2 bot accounts: one a normal bot and another with admin rights
masti
On 07.09.2022 08:14, Erik Sommer wrote:
Thanks Johnuniq and also xqt for the good hints,
at last I found my mistake. I'm operating two bot accounts at the moment. One does all the heavy lifting, but hasn't any sysop rights. The other one is for sysop actions only (was a wish by the community).
The solution provided by piwikibot is to use the env variable PYWIKIBOT_DIR. I did that to point to the alternative user-config. But I made a mistake and I kid you not: A leading whitespace infront of the variable :facepalm: ... therefor the framework fall back to the normal pywikibot config path and loaded the config of the non-sysop bot :-(.
Thanks to all for the help
Cheers Erik
On 06.09.22 11:38, Johnuniq wrote:
I upgraded all my pip modules yesterday, including pywikibot. Your line numbers are 18 lines different from mine in _pages.py so you might upgrade although that is unlikely to help.
Browsing around the source shows that @need_right('protect') is in site/_apisite.py and is responsible for the message: 'User "None" does not have required user right "protect"'.
site/_basesite.py returns None if self.logged_in() tests as false. My guess is that you are not logged in and it looks like it would be easy to stuff up Special:OAuthConsumerRegistration. I would try manually entering lines of code into python to mimic a simple bot start-up, then see if site.user() shows the bot name.
On Tue, Sep 6, 2022 at 4:04 PM Erik Sommer ersotech@posteo.de wrote:
This experiment was the initial reason for my post. I have one bot configured and I tried to protect some pages. This is stack trace from this experiment:
File "/home/esommer/workspace/WS_THEbotIT/service/protect.py", line 47, in task lemma.protect(reason="Schutz fertiger Seiten", File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py",
line 1998, in protect self.site.protect(self, protections, reason, **kwargs) File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/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 "protect"
The User "None" seems concerning. Is there a chance I screwed up the scopes when I generated the OAuth token at https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oa...
Cheers Erik
On 06.09.22 07:42, Johnuniq wrote:
I don't know but many years ago I ran an admin bot on a non-WMF wiki. A separate sysopnames variable was used to specify a user with admin credentials. Sysopnames was removed from pywikibot and whereas I've never used it, the theory is that now you have only a single bot user as defined in usernames. Pywikibot uses that user for normal actions and for admin actions. If admin privilege is needed, I think it first checks if the user has the required privilege. Some info on what I'm saying is at https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html
So if you had usernames['wikisource']['de'] = 'Example'
where Example has the bot and sysop flags, it should work. Try a simple script to delete a junk user subpage and report what happens. I don't know if it's possible with MediaWiki, but it's conceivable that pywikibot does not give itself admin credentials unless required (which might explain your debug results).
Johnuniq
On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer ersotech@posteo.de wrote:
No worries,
I do software dev for a living. It's all local and no one is checking in credentials. But that wasn't really the question here.
On 05.09.22 17:21, Roy Smith wrote:
I'm a total newbie at pywikibot, but let me address the general issue of putting credentials in config files.
Be very wary of how you store credentials. You should make sure they're in a file which is read-protected, and not in source control. Otherwise the entire world will have access to your secret credentials.
On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote:
Hi list,
I operate currently a bot on the German Wikisource. The bot was granted both groups, admin and bot. It is intended to be used as automated protection bot. I'm having trouble to put the right credentials in my user-config.py.
It is currently coded like following pseudo-code:
# -*- coding: utf-8 -*-
family = 'wikisource' mylang = 'de' usernames['wikisource']['de'] = '******'
authenticate['de.wikisource.org'] = (....*****.....)
the problem with this is that the framework only detect my bot as bot not as sysadmin. Groups taken from the debugging output: ['bot', '*', 'user', 'autoconfirmed']
What do I have to add to my config, that the bot also get picket up as sysadmin? I already read (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but doesn't make sense for me. It will not change anything if add the botname a second time to the usernames dictionary.
Best Regards
Erik Sommer
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
Create two Site instances and pass in different user= parameters to the constructor.
On Wed, Sep 7, 2022, 03:52 Erik Sommer ersotech@posteo.de wrote:
Now I don't use two accounts in the same script invocation. But I use a collection of scripts (self written, not part of pywikibot) and use them with different bot accounts. How to use different accounts in the same invocation, that I don't know. Can someone other help, because I see it similar as masti, this seems not possible anymore after the deprecation of sysopnames.
Erik
On 07.09.22 13:42, mastigm wrote:
how You use different configs in the same script?
PYWIKIBOT_DIR points to one config.
It used to be possible to specify normal and admin account in the same user-config.py
As I I understand it is not the case anymore.
What I need is a possibility to edit with a normal bot account and, for example if the page is empty delete it using bot admin account. Is this possible within one config?
PS: yes, I do have 2 bot accounts: one a normal bot and another with admin rights
masti
On 07.09.2022 08:14, Erik Sommer wrote:
Thanks Johnuniq and also xqt for the good hints,
at last I found my mistake. I'm operating two bot accounts at the moment. One does all the heavy lifting, but hasn't any sysop rights. The other one is for sysop actions only (was a wish by the community).
The solution provided by piwikibot is to use the env variable PYWIKIBOT_DIR. I did that to point to the alternative user-config. But I made a mistake and I kid you not: A leading whitespace infront of the variable :facepalm: ... therefor the framework fall back to the normal pywikibot config path and loaded the config of the non-sysop bot :-(.
Thanks to all for the help
Cheers Erik
On 06.09.22 11:38, Johnuniq wrote:
I upgraded all my pip modules yesterday, including pywikibot. Your line numbers are 18 lines different from mine in _pages.py so you might upgrade although that is unlikely to help.
Browsing around the source shows that @need_right('protect') is in site/_apisite.py and is responsible for the message: 'User "None" does not have required user right "protect"'.
site/_basesite.py returns None if self.logged_in() tests as false. My guess is that you are not logged in and it looks like it would be easy to stuff up Special:OAuthConsumerRegistration. I would try manually entering lines of code into python to mimic a simple bot start-up, then see if site.user() shows the bot name.
On Tue, Sep 6, 2022 at 4:04 PM Erik Sommer ersotech@posteo.de wrote:
This experiment was the initial reason for my post. I have one bot configured and I tried to protect some pages. This is stack trace from this experiment:
File "/home/esommer/workspace/WS_THEbotIT/service/protect.py",
line 47, in task lemma.protect(reason="Schutz fertiger Seiten", File
"/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py",
line 1998, in protect self.site.protect(self, protections, reason, **kwargs) File
"/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/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 "protect"
The User "None" seems concerning. Is there a chance I screwed up the scopes when I generated the OAuth token at
https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oa...
Cheers Erik
On 06.09.22 07:42, Johnuniq wrote:
I don't know but many years ago I ran an admin bot on a non-WMF wiki. A separate sysopnames variable was used to specify a user with admin credentials. Sysopnames was removed from pywikibot and whereas I've never used it, the theory is that now you have only a single bot user as defined in usernames. Pywikibot uses that user for normal actions and for admin actions. If admin privilege is needed, I think it first checks if the user has the required privilege. Some info on what I'm saying is at
https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html
So if you had usernames['wikisource']['de'] = 'Example'
where Example has the bot and sysop flags, it should work. Try a simple script to delete a junk user subpage and report what happens. I don't know if it's possible with MediaWiki, but it's conceivable that pywikibot does not give itself admin credentials unless required (which might explain your debug results).
Johnuniq
On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer ersotech@posteo.de wrote: > No worries, > > I do software dev for a living. It's all local and no one is > checking in credentials. But that wasn't really the question here. > > On 05.09.22 17:21, Roy Smith wrote: > > I'm a total newbie at pywikibot, but let me address the general > issue of putting credentials in config files. > > Be very wary of how you store credentials. You should make sure > they're in a file which is read-protected, and not in source > control. Otherwise the entire world will have access to your > secret credentials. > > > > On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de
wrote:
> > Hi list, > > I operate currently a bot on the German Wikisource. The bot was > granted both groups, admin and bot. It is intended to be used as > automated protection bot. I'm having trouble to put the right > credentials in my user-config.py. > > It is currently coded like following pseudo-code: > > # -*- coding: utf-8 -*- > > family = 'wikisource' > mylang = 'de' > usernames['wikisource']['de'] = '******' > > authenticate['de.wikisource.org'] = (....*****.....) > > the problem with this is that the framework only detect my bot as > bot not as sysadmin. Groups taken from the debugging output: > ['bot', '*', 'user', 'autoconfirmed'] > > What do I have to add to my config, that the bot also get picket > up as sysadmin? I already read > (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) > but doesn't make sense for me. It will not change anything if add > the botname a second time to the usernames dictionary. > > Best Regards > > Erik Sommer > > _______________________________________________ > pywikibot mailing list -- pywikibot@lists.wikimedia.org > To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org > > > > _______________________________________________ > pywikibot mailing list -- pywikibot@lists.wikimedia.org > To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org > > _______________________________________________ > pywikibot mailing list -- pywikibot@lists.wikimedia.org > To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org _______________________________________________ pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
Not sure if this works, as I had the feeling the parameter user in the constructor was more or less irrelevant. (Provided X Site Object got Y from user-config.py)
Erik
On 07.09.22 19:52, YiFei Zhu wrote:
Create two Site instances and pass in different user= parameters to the constructor.
On Wed, Sep 7, 2022, 03:52 Erik Sommer ersotech@posteo.de wrote:
Now I don't use two accounts in the same script invocation. But I use a collection of scripts (self written, not part of pywikibot) and use them with different bot accounts. How to use different accounts in the same invocation, that I don't know. Can someone other help, because I see it similar as masti, this seems not possible anymore after the deprecation of sysopnames. Erik On 07.09.22 13:42, mastigm wrote: > how You use different configs in the same script? > > PYWIKIBOT_DIR points to one config. > > It used to be possible to specify normal and admin account in the same > user-config.py > > As I I understand it is not the case anymore. > > What I need is a possibility to edit with a normal bot account and, > for example if the page is empty delete it using bot admin account. Is > this possible within one config? > > PS: yes, I do have 2 bot accounts: one a normal bot and another with > admin rights > > masti > > > On 07.09.2022 08:14, Erik Sommer wrote: >> Thanks Johnuniq and also xqt for the good hints, >> >> at last I found my mistake. I'm operating two bot accounts at the >> moment. One does all the heavy lifting, but hasn't any sysop rights. >> The other one is for sysop actions only (was a wish by the community). >> >> The solution provided by piwikibot is to use the env >> variable PYWIKIBOT_DIR. I did that to point to the alternative >> user-config. But I made a mistake and I kid you not: A leading >> whitespace infront of the variable :facepalm: ... therefor the >> framework fall back to the normal pywikibot config path and loaded >> the config of the non-sysop bot :-(. >> >> Thanks to all for the help >> >> Cheers Erik >> >> On 06.09.22 11:38, Johnuniq wrote: >>> I upgraded all my pip modules yesterday, including pywikibot. Your >>> line numbers are 18 lines different from mine in _pages.py so you >>> might upgrade although that is unlikely to help. >>> >>> Browsing around the source shows that @need_right('protect') is in >>> site/_apisite.py and is responsible for the message: 'User "None" does >>> not have required user right "protect"'. >>> >>> site/_basesite.py returns None if self.logged_in() tests as false. My >>> guess is that you are not logged in and it looks like it would be easy >>> to stuff up Special:OAuthConsumerRegistration. I would try manually >>> entering lines of code into python to mimic a simple bot start-up, >>> then see if site.user() shows the bot name. >>> >>> On Tue, Sep 6, 2022 at 4:04 PM Erik Sommer <ersotech@posteo.de> wrote: >>>> This experiment was the initial reason for my post. I have one bot >>>> configured and I tried to protect some pages. This is stack trace from >>>> this experiment: >>>> >>>> File "/home/esommer/workspace/WS_THEbotIT/service/protect.py", >>>> line >>>> 47, in task >>>> lemma.protect(reason="Schutz fertiger Seiten", >>>> File >>>> "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py", >>>> >>>> line 1998, in protect >>>> self.site.protect(self, protections, reason, **kwargs) >>>> File >>>> "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/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 "protect" >>>> >>>> The User "None" seems concerning. Is there a chance I screwed up the >>>> scopes when I generated the OAuth token at >>>> https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oauth2? >>>> >>>> >>>> Cheers Erik >>>> >>>> On 06.09.22 07:42, Johnuniq wrote: >>>>> I don't know but many years ago I ran an admin bot on a non-WMF wiki. >>>>> A separate sysopnames variable was used to specify a user with admin >>>>> credentials. Sysopnames was removed from pywikibot and whereas I've >>>>> never used it, the theory is that now you have only a single bot user >>>>> as defined in usernames. Pywikibot uses that user for normal actions >>>>> and for admin actions. If admin privilege is needed, I think it first >>>>> checks if the user has the required privilege. Some info on what I'm >>>>> saying is at >>>>> https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html >>>>> >>>>> >>>>> So if you had >>>>> usernames['wikisource']['de'] = 'Example' >>>>> >>>>> where Example has the bot and sysop flags, it should work. Try a >>>>> simple script to delete a junk user subpage and report what >>>>> happens. I >>>>> don't know if it's possible with MediaWiki, but it's conceivable that >>>>> pywikibot does not give itself admin credentials unless required >>>>> (which might explain your debug results). >>>>> >>>>> Johnuniq >>>>> >>>>> On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer <ersotech@posteo.de> >>>>> wrote: >>>>>> No worries, >>>>>> >>>>>> I do software dev for a living. It's all local and no one is >>>>>> checking in credentials. But that wasn't really the question here. >>>>>> >>>>>> On 05.09.22 17:21, Roy Smith wrote: >>>>>> >>>>>> I'm a total newbie at pywikibot, but let me address the general >>>>>> issue of putting credentials in config files. >>>>>> >>>>>> Be very wary of how you store credentials. You should make sure >>>>>> they're in a file which is read-protected, and not in source >>>>>> control. Otherwise the entire world will have access to your >>>>>> secret credentials. >>>>>> >>>>>> >>>>>> >>>>>> On Sep 5, 2022, at 10:14 AM, Erik Sommer <ersotech@posteo.de> wrote: >>>>>> >>>>>> Hi list, >>>>>> >>>>>> I operate currently a bot on the German Wikisource. The bot was >>>>>> granted both groups, admin and bot. It is intended to be used as >>>>>> automated protection bot. I'm having trouble to put the right >>>>>> credentials in my user-config.py. >>>>>> >>>>>> It is currently coded like following pseudo-code: >>>>>> >>>>>> # -*- coding: utf-8 -*- >>>>>> >>>>>> family = 'wikisource' >>>>>> mylang = 'de' >>>>>> usernames['wikisource']['de'] = '******' >>>>>> >>>>>> authenticate['de.wikisource.org <http://de.wikisource.org>'] = (....*****.....) >>>>>> >>>>>> the problem with this is that the framework only detect my bot as >>>>>> bot not as sysadmin. Groups taken from the debugging output: >>>>>> ['bot', '*', 'user', 'autoconfirmed'] >>>>>> >>>>>> What do I have to add to my config, that the bot also get picket >>>>>> up as sysadmin? I already read >>>>>> (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) >>>>>> but doesn't make sense for me. It will not change anything if add >>>>>> the botname a second time to the usernames dictionary. >>>>>> >>>>>> Best Regards >>>>>> >>>>>> Erik Sommer >>>>>> >>>>>> _______________________________________________ >>>>>> pywikibot mailing list -- pywikibot@lists.wikimedia.org >>>>>> To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> pywikibot mailing list -- pywikibot@lists.wikimedia.org >>>>>> To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org >>>>>> >>>>>> _______________________________________________ >>>>>> pywikibot mailing list -- pywikibot@lists.wikimedia.org >>>>>> To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org >>>>> _______________________________________________ >>>>> pywikibot mailing list -- pywikibot@lists.wikimedia.org >>>>> To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org >>>> _______________________________________________ >>>> pywikibot mailing list -- pywikibot@lists.wikimedia.org >>>> To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org >>> _______________________________________________ >>> pywikibot mailing list -- pywikibot@lists.wikimedia.org >>> To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org >> _______________________________________________ >> pywikibot mailing list -- pywikibot@lists.wikimedia.org >> To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org > _______________________________________________ > pywikibot mailing list -- pywikibot@lists.wikimedia.org > To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org _______________________________________________ pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list --pywikibot@lists.wikimedia.org To unsubscribe send an email topywikibot-leave@lists.wikimedia.org
All I will say is that it is the documented API [1] to use nn-default usernames, and I have used it before, years ago. If it doesn't work now it is a bug.
[1] https://github.com/wikimedia/pywikibot/blob/f57f7420edcab0980c287aaf9557edc1...
On Wed, Sep 7, 2022 at 10:48 AM Erik Sommer ersotech@posteo.de wrote:
Not sure if this works, as I had the feeling the parameter user in the constructor was more or less irrelevant. (Provided X Site Object got Y from user-config.py)
Erik
On 07.09.22 19:52, YiFei Zhu wrote:
Create two Site instances and pass in different user= parameters to the constructor.
On Wed, Sep 7, 2022, 03:52 Erik Sommer ersotech@posteo.de wrote:
Now I don't use two accounts in the same script invocation. But I use a collection of scripts (self written, not part of pywikibot) and use them with different bot accounts. How to use different accounts in the same invocation, that I don't know. Can someone other help, because I see it similar as masti, this seems not possible anymore after the deprecation of sysopnames.
Erik
On 07.09.22 13:42, mastigm wrote:
how You use different configs in the same script?
PYWIKIBOT_DIR points to one config.
It used to be possible to specify normal and admin account in the same user-config.py
As I I understand it is not the case anymore.
What I need is a possibility to edit with a normal bot account and, for example if the page is empty delete it using bot admin account. Is this possible within one config?
PS: yes, I do have 2 bot accounts: one a normal bot and another with admin rights
masti
On 07.09.2022 08:14, Erik Sommer wrote:
Thanks Johnuniq and also xqt for the good hints,
at last I found my mistake. I'm operating two bot accounts at the moment. One does all the heavy lifting, but hasn't any sysop rights. The other one is for sysop actions only (was a wish by the community).
The solution provided by piwikibot is to use the env variable PYWIKIBOT_DIR. I did that to point to the alternative user-config. But I made a mistake and I kid you not: A leading whitespace infront of the variable :facepalm: ... therefor the framework fall back to the normal pywikibot config path and loaded the config of the non-sysop bot :-(.
Thanks to all for the help
Cheers Erik
On 06.09.22 11:38, Johnuniq wrote:
I upgraded all my pip modules yesterday, including pywikibot. Your line numbers are 18 lines different from mine in _pages.py so you might upgrade although that is unlikely to help.
Browsing around the source shows that @need_right('protect') is in site/_apisite.py and is responsible for the message: 'User "None" does not have required user right "protect"'.
site/_basesite.py returns None if self.logged_in() tests as false. My guess is that you are not logged in and it looks like it would be easy to stuff up Special:OAuthConsumerRegistration. I would try manually entering lines of code into python to mimic a simple bot start-up, then see if site.user() shows the bot name.
On Tue, Sep 6, 2022 at 4:04 PM Erik Sommer ersotech@posteo.de wrote:
This experiment was the initial reason for my post. I have one bot configured and I tried to protect some pages. This is stack trace from this experiment:
File "/home/esommer/workspace/WS_THEbotIT/service/protect.py",
line 47, in task lemma.protect(reason="Schutz fertiger Seiten", File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py",
line 1998, in protect self.site.protect(self, protections, reason, **kwargs) File "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/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 "protect"
The User "None" seems concerning. Is there a chance I screwed up the scopes when I generated the OAuth token at https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oa...
Cheers Erik
On 06.09.22 07:42, Johnuniq wrote: > I don't know but many years ago I ran an admin bot on a non-WMF wiki. > A separate sysopnames variable was used to specify a user with admin > credentials. Sysopnames was removed from pywikibot and whereas I've > never used it, the theory is that now you have only a single bot user > as defined in usernames. Pywikibot uses that user for normal actions > and for admin actions. If admin privilege is needed, I think it first > checks if the user has the required privilege. Some info on what I'm > saying is at > https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html > > > So if you had > usernames['wikisource']['de'] = 'Example' > > where Example has the bot and sysop flags, it should work. Try a > simple script to delete a junk user subpage and report what > happens. I > don't know if it's possible with MediaWiki, but it's conceivable that > pywikibot does not give itself admin credentials unless required > (which might explain your debug results). > > Johnuniq > > On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer ersotech@posteo.de > wrote: >> No worries, >> >> I do software dev for a living. It's all local and no one is >> checking in credentials. But that wasn't really the question here. >> >> On 05.09.22 17:21, Roy Smith wrote: >> >> I'm a total newbie at pywikibot, but let me address the general >> issue of putting credentials in config files. >> >> Be very wary of how you store credentials. You should make sure >> they're in a file which is read-protected, and not in source >> control. Otherwise the entire world will have access to your >> secret credentials. >> >> >> >> On Sep 5, 2022, at 10:14 AM, Erik Sommer ersotech@posteo.de wrote: >> >> Hi list, >> >> I operate currently a bot on the German Wikisource. The bot was >> granted both groups, admin and bot. It is intended to be used as >> automated protection bot. I'm having trouble to put the right >> credentials in my user-config.py. >> >> It is currently coded like following pseudo-code: >> >> # -*- coding: utf-8 -*- >> >> family = 'wikisource' >> mylang = 'de' >> usernames['wikisource']['de'] = '******' >> >> authenticate['de.wikisource.org'] = (....*****.....) >> >> the problem with this is that the framework only detect my bot as >> bot not as sysadmin. Groups taken from the debugging output: >> ['bot', '*', 'user', 'autoconfirmed'] >> >> What do I have to add to my config, that the bot also get picket >> up as sysadmin? I already read >> (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) >> but doesn't make sense for me. It will not change anything if add >> the botname a second time to the usernames dictionary. >> >> Best Regards >> >> Erik Sommer >> >> _______________________________________________ >> pywikibot mailing list -- pywikibot@lists.wikimedia.org >> To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org >> >> >> >> _______________________________________________ >> pywikibot mailing list -- pywikibot@lists.wikimedia.org >> To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org >> >> _______________________________________________ >> pywikibot mailing list -- pywikibot@lists.wikimedia.org >> To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org > _______________________________________________ > pywikibot mailing list -- pywikibot@lists.wikimedia.org > To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org _______________________________________________ pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
how You use different configs in the same script?
In my case, I would first run a script to select which user I needed and that script copied the appropriate user-config file. After that, I would run a second script that used pywikibot. I have not tried YiFei Zhu's solution.