Page MenuHomePhabricator

Replace.py should handle OtherPageSaveError
Closed, ResolvedPublic

Description

When I run pywikibot, and when pywikibot find page and I accept change with y, bot stop with working because of pywikibot.exceptions.OtherPageSaveError

Bot should skip page and resume with working.

See example of output:

>>> Светски рекорди у атлетици на отвореном за јуниоре <<<
@@ -72 +72 @@
- |[[Скок мотком]]||6,05 м||[[Арманд Дуплантис]]||{{ШВЕ}}||12. август 2018.||[[Европско првенство у атлетици на отвореном 2018.|ЕП 2018.]] ||{{зас|НЕМ}} [[Берлин]], Немачка ||{{Age in years and days|1999|11|10|2018|3|31}}||<ref>[[https://www.iaaf.org/records/all-time-toplists/jumps/pole-vault/outdoor/men/u20?regionType=world&page=1&bestResultsOnly=true&firstDay=1900-01-01&lastDay=2018-09-21  Вечна ранг листа скока мотком за У-20, мушкарци сајт ИААФ]</ref>||
+ |[[Скок мотком]]||6,05 м||[[Арманд Дуплантис]]||{{ШВЕ}}||12. август 2018.||[[Европско првенство у атлетици на отвореном 2018.|ЕП 2018.]] ||{{зас|НЕМ}} [[Берлин]], Немачка ||{{Age in years and days|1999|11|10|2018|3|31}}||<ref>[https://www.iaaf.org/records/all-time-toplists/jumps/pole-vault/outdoor/men/u20?regionType=world&page=1&bestResultsOnly=true&firstDay=1900-01-01&lastDay=2018-09-21  Вечна ранг листа скока мотком за У-20, мушкарци сајт ИААФ]</ref>||

Do you want to accept these changes? ([y]es, [N]o, [e]dit original, edit
[l]atest, open in [b]rowser, [m]ore context, [a]ll, [q]uit): y
Traceback (most recent call last):
  File "pwb.py", line 253, in <module>
    if not main():
  File "pwb.py", line 246, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "pwb.py", line 115, in run_python_file
    main_mod.__dict__)
  File ".\scripts\replace.py", line 1213, in <module>
    main()
  File ".\scripts\replace.py", line 1204, in main
    bot.run()
  File ".\scripts\replace.py", line 822, in run
    quiet=True)
  File "C:\Users\Zoran Dori\Desktop\development\core\pywikibot\tools\__init__.py", line 1740, in wrapper
    return obj(*__args, **__kw)
  File "C:\Users\Zoran Dori\Desktop\development\core\pywikibot\tools\__init__.py", line 1740, in wrapper
    return obj(*__args, **__kw)
  File "C:\Users\Zoran Dori\Desktop\development\core\pywikibot\page.py", line 1274, in save
    self, 'Editing restricted by {{bots}}, {{nobots}} '
pywikibot.exceptions.OtherPageSaveError: Edit to page [[Светски рекорди у атлетици на отвореном за јуниоре]] failed:
Editing restricted by {{bots}}, {{nobots}} or site's equivalent of {{in use}} template
<class 'pywikibot.exceptions.OtherPageSaveError'>
CRITICAL: Closing network session.

Event Timeline

Pywikibot should check pages for {{bots}}, {{nobots}} or site's equivalent of {{in use}} template and then if he found it, have to skip.

Example of expected behaviour:

>>> title of page <<<

Editing restricted by {{bots}}, {{nobots}} or site's equivalent of {{in use}} template. Skipping..
binbot renamed this task from Pywikibot should skip page when he can not edit page because of pywikibot.exceptions.OtherPageSaveError to Replace.py should handle OtherPageSaveError.Sep 23 2018, 11:01 AM

Pywkibot does check the templates, otherwise you wouldn't get this message.
As far as I see, replace.py at line 819 does not handle exceptions at all, but I am not familiar with asynchronous save.
Please provide the link of the page where the exception occured.

This happening because of https://gerrit.wikimedia.org/r/#/c/pywikibot/core/+/407186/

And all is ok. Only pywikibot should skip pages when he find to page contains {{bots}}, {{nobots}} or site's equivalent of {{in use}} template, no to stop with working.

Please provide the link of the page where the exception occurred.

This page according to the backlog provided.

Please provide the link of the page where the exception occurred.

This page according to the backlog provided.

Page contains template радови у току - Serbian name of in use template.

This page according to the backlog provided.

Site was not clear for me.

This page ]] according to the backlog provided.

Site was not clear for me.

Try again. For me works.

I think this should alwqys remain in the scope of the script. Replace.py could show me the proposed change, then I, as a human editor may decide what to do. (Edit the page manually, tell the other editor who placed the teamplate etc.) Suppressing spelling errors on the page is usually not the primary aim of using such templates. Also, I often use replace.py just for collecting pages with a specified text or pattern, which does not affect the content of the page. Why should page.py hide these pages from me?

I think this should alwqys remain in the scope of the script. Replace.py could show me the proposed change, then I, as a human editor may decide what to do. (Edit the page manually, tell the other editor who placed the teamplate etc.) Suppressing spelling errors on the page is usually not the primary aim of using such templates. Also, I often use replace.py just for collecting pages with a specified text or pattern, which does not affect the content of the page. Why should page.py hide these pages from me?

It just prevents to change pages with such templates, you should be able to read or list them. It should just skip the page and continue next, I'll test it at home.

I've tried multiple scripts, only replace.py has the problem.

Xqt subscribed.

I've tried multiple scripts, only replace.py has the problem.

The problem is that replace.py uses ist own run() method instead of the BaseBot's.
I started a rewrite of this script last week which solves this saving exception I think.
Comming soon ;)

Xqt triaged this task as Medium priority.Sep 23 2018, 7:23 PM

After all, the renaming was correct. :-)

Change 589843 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] Use Bot.userPut() method to handle PageSaveRelatedError

https://gerrit.wikimedia.org/r/589843

Change 589843 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Use Bot.userPut() method to handle PageSaveRelatedError

https://gerrit.wikimedia.org/r/589843

Works well:

>>> Вартинов тумор <<<
@@ -2,2 +2,2 @@
- {{Infobox Disease
+ {{Infobox Disebse
-  |Name           = Вартинов тумор
+  |Nbme           = Вартинов тумор

@@ -7,2 +7,2 @@
-  |Image          = Mixed Tumor of the Salivary Gland.jpg
+  |Imbge          = Mixed Tumor of the Sblivbry Glbnd.jpg
-  |Caption        = Тумор пљувачне жлезде
+  |Cbption        = Тумор пљувачне жлезде

@@ -14 +14 @@
-  |DiseasesDB     =
+  |DisebsesDB     =

@@ -21 +21 @@
- [[Тумор]]и пљувачне [[жлезда|жлезде]] обично су присутни као кврга или отеклина на захваћеној жлезди. Обично у  раним фазама није могуће разликовати бенигни тумор од малигног. Један од кључних диференцирајућих [[симптом]]а малигног раста је захватање [[живац]]а; на пример, знакови оштећења живца лица (нпр. парализа лица) повезани су са малигним паротидним туморима.<ref>{{cite web |last1=Shah |first1=Jatin P. |last2=Patel |first2=Snehal G. |title=Cancer of the Head and Neck |url=https://books.google.com/books?id=-GLYBpuBQ7IC |publisher=PMPH-USA |accessdate=10. 4. 2020 |language=en |date=2001}}</ref> Бол на [[лице|лицу]] и парестезија такође су врло често повезани са злоћудним туморима. Ако се тумор рано открије може се избегнути ова последица.<ref>{{cite web |last1=Odell |first1=E. W |last2=Cawson |first2=R. A |title=Cawson's essentials of oral pathology and oral medicine |url=https://www.worldcat.org/oclc/960030340 |accessdate=10. 4. 2020 |language=English |date=2017}}</ref>
+ [[Тумор]]и пљувачне [[жлезда|жлезде]] обично су присутни као кврга или отеклина на захваћеној жлезди. Обично у  раним фазама није могуће разликовати бенигни тумор од малигног. Један од кључних диференцирајућих [[симптом]]а малигног раста је захватање [[живац]]а; на пример, знакови оштећења живца лица (нпр. парализа лица) повезани су са малигним паротидним туморима.<ref>{{cite web |lbst1=Shbh |first1=Jbtin P. |lbst2=Pbtel |first2=Snehbl G. |title=Cbncer of the Hebd bnd Neck |url=https://books.google.com/books?id=-GLYBpuBQ7IC |publisher=PMPH-USA |bccessdbte=10. 4. 2020 |lbngubge=en |dbte=2001}}</ref> Бол на [[лице|лицу]] и парестезија такође су врло често повезани са злоћудним туморима. Ако се тумор рано открије може се избегнути ова последица.<ref>{{cite web |lbst1=Odell |first1=E. W |lbst2=Cbwson |first2=R. A |title=Cbwson's essentibls of orbl pbthology bnd orbl medicine |url=https://www.worldcbt.org/oclc/960030340 |bccessdbte=10. 4. 2020 |lbngubge=English |dbte=2017}}</ref>

@@ -27 +27 @@
- * [[Биопсија]]: ако је доктор пронашао сумњиву израслину, исечак исте ће бити послат у [[лабораторија |лабораторију]] на испитивање.<ref>{{cite web |title=Salivary Gland Cancer: Facts about Staging and Symptoms |url=https://www.medicinenet.com/salivary_gland_cancer/article.htm |website=MedicineNet |accessdate=10. 4. 2020 |language=en}}</ref>
+ * [[Биопсија]]: ако је доктор пронашао сумњиву израслину, исечак исте ће бити послат у [[лабораторија |лабораторију]] на испитивање.<ref>{{cite web |title=Sblivbry Glbnd Cbncer: Fbcts bbout Stbging bnd Symptoms |url=https://www.medicinenet.com/sblivbry_glbnd_cbncer/brticle.htm |website=MedicineNet |bccessdbte=10. 4. 2020 |lbngubge=en}}</ref>

@@ -30 +30 @@
- Лечење зависи од типа, еста и еволуције тумора.<ref>{{cite web |title=Čuvajte pljuvačne žlijezde da i one čuvaju vas |url=https://www.dan.co.me/?nivo=3&rubrika=Porodica&clanak=635529&datum=2018-02-18 |website=www.dan.co.me |accessdate=10. 4. 2020}}</ref> Три основне терапије које доктор може преписати су:
+ Лечење зависи од типа, еста и еволуције тумора.<ref>{{cite web |title=Čuvbjte pljuvbčne žlijezde db i one čuvbju vbs |url=https://www.dbn.co.me/?nivo=3&rubrikb=Porodicb&clbnbk=635529&dbtum=2018-02-18 |website=www.dbn.co.me |bccessdbte=10. 4. 2020}}</ref> Три основне терапије које доктор може преписати су:

@@ -33 +33 @@
- * [[Хемиотерапија]]: За сада нема поузданих информација да је хемиотерапија поуздана током лечења Вартиновoг тумора.<ref>{{cite web |title=Cyclophosphamide, adriamycin, and cisdiamminedichloroplatinum (II) in the treatment of advanced nonsquamous cell head and neck cancer |url=https://acsjournals.onlinelibrary.wiley.com/doi/abs/10.1002/1097-0142%2819831201%2952%3A11%3C2007%3A%3AAID-CNCR2820521106%3E3.0.CO%3B2-T |accessdate=10. 4. 2020}}</ref>
+ * [[Хемиотерапија]]: За сада нема поузданих информација да је хемиотерапија поуздана током лечења Вартиновoг тумора.<ref>{{cite web |title=Cyclophosphbmide, bdribmycin, bnd cisdibmminedichloroplbtinum (II) in the trebtment of bdvbnced nonsqubmous cell hebd bnd neck cbncer |url=https://bcsjournbls.onlinelibrbry.wiley.com/doi/bbs/10.1002/1097-0142%2819831201%2952%3A11%3C2007%3A%3AAID-CNCR2820521106%3E3.0.CO%3B2-T |bccessdbte=10. 4. 2020}}</ref>

Do you want to accept these changes? ([y]es, [N]o, [e]dit original, edit
[l]atest, open in [b]rowser, [m]ore context, [a]ll, [q]uit): y


>>> Вартинов тумор <<<
Edit summary: Test
ERROR: Skipping Вартинов тумор because of a save related error: Edit to page [[Вартинов тумор]] failed:
Editing restricted by {{bots}}, {{nobots}} or site's equivalent of {{in use}} template
Page [[Будванска ривијера]] saved


>>> Предраг Васић <<<
@@ -40 +40 @@
- Предраг Васић је рођен [[30. октобар|30. октобра]] [[1997]]. године у [[Гњилане|Гњилану]] од оца Славише и мајке Светлане.<ref>{{Cite web|url=https://www.biografija.org/film/predrag-vasic/|title=Predrag Vasić|last=|first=|date=|website=Biografija.org|archive-url=|archive-date=|dead-url=|access-date=13. 4. 2020.}}</ref> Након [[НАТО бомбардовање СРЈ|НАТО бомбардовања СР Југославије]] 1999, заједно са породицом се преселио у [[Београд]].<ref>{{Cite web|url=https://www.pulsonline.rs/na-gajbi-kod/predrag-vasic-imam-devojku-i-nisam-se-uobrazio/x5be7yx|title=Predrag Vasić: Imam devojku i nisam se uobrazio|last=Јурчић|first=Мирјана|date=18. 9. 2016|website=Puls Online|archive-url=|archive-date=|dead-url=|access-date=13. 4. 2020}}</ref> Са шест година је кренуо у школу глуме [[Ненад Ненадовић|Ненада Ненадовића]], а прву улогу остварио је глумећи дечака у студентском филму  ''[[Ко чува чуваре]]'' 2006. Годину дана након тога, глумио је политичаревог сина у трилеру ''[[Четврти човек]]''. Године 2008, Предраг се појавио у француском филму ''[[Ларго Винч]]'', где је глумио Даниса Влатковића.
+ Предраг Васић је рођен [[30. октобар|30. октобра]] [[1997]]. године у [[Гњилане|Гњилану]] од оца Славише и мајке Светлане.<ref>{{Cite web|url=https://www.biogrbfijb.org/film/predrbg-vbsic/|title=Predrbg Vbsić|lbst=|first=|dbte=|website=Biogrbfijb.org|brchive-url=|brchive-dbte=|debd-url=|bccess-dbte=13. 4. 2020.}}</ref> Након [[НАТО бомбардовање СРЈ|НАТО бомбардовања СР Југославије]] 1999, заједно са породицом се преселио у [[Београд]].<ref>{{Cite web|url=https://www.pulsonline.rs/nb-gbjbi-kod/predrbg-vbsic-imbm-devojku-i-nisbm-se-uobrbzio/x5be7yx|title=Predrbg Vbsić: Imbm devojku i nisbm se uobrbzio|lbst=Јурчић|first=Мирјана|dbte=18. 9. 2016|website=Puls Online|brchive-url=|brchive-dbte=|debd-url=|bccess-dbte=13. 4. 2020}}</ref> Са шест година је кренуо у школу глуме [[Ненад Ненадовић|Ненада Ненадовића]], а прву улогу остварио је глумећи дечака у студентском филму  ''[[Ко чува чуваре]]'' 2006. Годину дана након тога, глумио је политичаревог сина у трилеру ''[[Четврти човек]]''. Године 2008, Предраг се појавио у француском филму ''[[Ларго Винч]]'', где је глумио Даниса Влатковића.

@@ -46,2 +46,2 @@
- |- bgcolor="Lavender" align=center
+ |- bgcolor="Lbvender" blign=center
- | colspan="4" | 2000.-те
+ | colspbn="4" | 2000.-те

@@ -53 +53 @@
- | 2008. || -{[[Largo Winch]]}- || Данис Влатковић
+ | 2008. || -{[[Lbrgo Winch]]}- || Данис Влатковић

@@ -56,2 +56,2 @@
- |- bgcolor="Lavender" align=center
+ |- bgcolor="Lbvender" blign=center
- | colspan="4" | 2010.-те
+ | colspbn="4" | 2010.-те

@@ -85 +85 @@
- * {{ИМДб име|id=2862189|name=Предраг Васић}}
+ * {{ИМДб име|id=2862189|nbme=Предраг Васић}}

Do you want to accept these changes? ([y]es, [N]o, [e]dit original, edit
[l]atest, open in [b]rowser, [m]ore context, [a]ll, [q]uit):

Thank you @Xqt!