ivanhercaz / CanaryBot

CanaryBot works in the Wikimedia projects mainly in maintenance tasks!
1 stars 0 forks source link

Exception in try block breaks the script #1

Closed ivanhercaz closed 6 years ago

ivanhercaz commented 6 years ago

There was an exception in the try statement of the "remove full stop" option. After read the stack trace I think the error is caused due log.check(e, logName, mode="csv"), because e had not all the keys specified in the log.py module (time, item, key, msg).

I tried to solve it with #2e14789 but I have to wait to another similar issue to check the error. This happened when I try to remove the full stop of the item Q178493, in which the full stop is separated of the last word (senegalese .), so it is another error that I have to fix (#2):

  Q178493
 - it-desc:     calciatore senegalese  . 
 + Replacement: calciatore senegalese

This error is very important because it breaks the script and cause the script doesn't execute fine the log.update() and doesn't create the HTML CSV-viewer.

Stack trace:

Q178493 it-desc full stop removed                                                                                                    
WARNING: API error modification-failed: Item [[Q2821366|Q2821366]] already has label "Abdoulaye Diallo" associated with language code
using the same description text.                                                                                                     
Edit to page [[wikidata:Q178493]] failed:                                                                                            
modification-failed: Item [[Q2821366|Q2821366]] already has label "Abdoulaye Diallo" associated with language code it, using the same
ription text. [messages:[{'name': 'wikibase-validator-label-with-description-conflict', 'parameters': ['Abdoulaye Diallo', 'it', '[[Q
66|Q2821366]]'], 'html': {'*': 'El elemento <a href="/wiki/Q2821366" title="Q2821366">Q2821366</a> ya tiene la etiqueta "Abdoulaye Di
 asociada con el código de idioma it, usando el mismo texto de descripción.'}}]; help:See https://www.wikidata.org/w/api.php for API 
. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt;
notice of API deprecations and breaking changes.]                                                                                    

Updating log...                                                                                                                      

Traceback (most recent call last):                                                                                                   
  File "/srv/paws/pwb/pywikibot/page.py", line 118, in handle                                                                        
    func(self, *args, **kwargs)                                                                                                      
  File "/srv/paws/pwb/pywikibot/page.py", line 4059, in editEntity                                                                   
    baserevid=baserevid, **kwargs)                                                                                                   
  File "/srv/paws/pwb/pywikibot/site.py", line 1312, in callee                                                                       
    return fn(self, *args, **kwargs)                                                                                                 
  File "/srv/paws/pwb/pywikibot/site.py", line 7668, in editEntity                                                                   
    data = req.submit()                                                                                                              
  File "/srv/paws/pwb/pywikibot/data/api.py", line 2195, in submit                                                                   
    raise APIError(**result['error'])                                                                                                
pywikibot.data.api.APIError: modification-failed: Item [[Q2821366|Q2821366]] already has label "Abdoulaye Diallo" associated with lan
 code it, using the same description text. [messages:[{'name': 'wikibase-validator-label-with-description-conflict', 'parameters': ['
laye Diallo', 'it', '[[Q2821366|Q2821366]]'], 'html': {'*': 'El elemento <a href="/wiki/Q2821366" title="Q2821366">Q2821366</a> ya ti
a etiqueta "Abdoulaye Diallo" asociada con el código de idioma it, usando el mismo texto de descripción.'}}]; help:See https://www.wi
a.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listin
diawiki-api-announce&gt; for notice of API deprecations and breaking changes.]                                                       

During handling of the above exception, another exception occurred:                                                                  

Traceback (most recent call last):                                                                                                   
  File "fullstopschecker.py", line 96, in editDesc                                                                                   
    itemPage.editDescriptions(replacement, summary=summary["removed"])                                                               
  File "/srv/paws/pwb/pywikibot/page.py", line 4091, in editDescriptions                                                             
    self.editEntity(data, **kwargs)                                                                                                  
  File "/srv/paws/pwb/pywikibot/page.py", line 136, in wrapper                                                                       
    handle(func, self, *args, **kwargs)                                                                                              
  File "/srv/paws/pwb/pywikibot/page.py", line 128, in handle                                                                        
    raise pywikibot.OtherPageSaveError(self, err)                                                                                    
pywikibot.exceptions.OtherPageSaveError: Edit to page [[wikidata:Q178493]] failed:                                                   
modification-failed: Item [[Q2821366|Q2821366]] already has label "Abdoulaye Diallo" associated with language code it, using the same
ription text. [messages:[{'name': 'wikibase-validator-label-with-description-conflict', 'parameters': ['Abdoulaye Diallo', 'it', '[[Q
66|Q2821366]]'], 'html': {'*': 'El elemento <a href="/wiki/Q2821366" title="Q2821366">Q2821366</a> ya tiene la etiqueta "Abdoulaye Di
 asociada con el código de idioma it, usando el mismo texto de descripción.'}}]; help:See https://www.wikidata.org/w/api.php for API 
. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt;
notice of API deprecations and breaking changes.]                                                                                    

During handling of the above exception, another exception occurred:                                                                  

Traceback (most recent call last):                                                                                                   
  File "fullstopschecker.py", line 314, in <module>                                                                                  
    checkDesc(query, editMode)                                                                                                       
  File "fullstopschecker.py", line 242, in checkDesc                                                                                 
    edit = editDesc(item, key, description, newDescription, count, editMode, editGroup, logName)                                     
  File "fullstopschecker.py", line 113, in editDesc                                                                                  
    log.check(e, logName, mode="csv")                                                                                                
  File "/home/paws/CanaryBot/log.py", line 105, in check                                                                             
    update(info, script, fullNameLog, nowFormat, generateHTML, mode)                                                                 
  File "/home/paws/CanaryBot/log.py", line 62, in update                                                                             
    row = info["time"], info["item"], info["key"], info["msg"]                                                                       
TypeError: 'OtherPageSaveError' object is not subscriptable                                                                          
<class 'TypeError'>                                                                                                                  
CRITICAL: Closing network session.                                                                                                   
@PAWS:~/CanaryBot$
ivanhercaz commented 6 years ago

Yesterday I fixed this bug with the commit 2e14789.