Page MenuHomePhabricator

nowcommons.py fails with misleading error
Open, MediumPublic

Description

nowcommons fails:

C:\pwb\GIT\core>pwb.py nowcommons -simulate
Retrieving 30 pages from wikipedia:de.


>>> Datei:Fraukirch Umgebung.jpg <<<
No page is using "Fraukirch Umgebung.jpg" anymore.
Traceback (most recent call last):
  File "C:\pwb\GIT\core\pwb.py", line 256, in <module>
    if not main():
  File "C:\pwb\GIT\core\pwb.py", line 250, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "C:\pwb\GIT\core\pwb.py", line 121, in run_python_file
    main_mod.__dict__)
  File ".\scripts\nowcommons.py", line 485, in <module>
    main()
  File ".\scripts\nowcommons.py", line 482, in main
    bot.run()
  File ".\scripts\nowcommons.py", line 452, in run
    pywikibot.output(u'%s' % e[0])
IndexError: tuple index out of range
<type 'exceptions.IndexError'>
CRITICAL: Closing network session.

but the error is quite misleading. I repaired that line 452 (removing that index) and added an additional exception() call above. Then I get:

C:\pwb\GIT\core>pwb.py nowcommons -simulate
Retrieving 32 pages from wikipedia:de.


>>> Datei:Fraukirch Umgebung.jpg <<<
No page is using "Fraukirch Umgebung.jpg" anymore.
ERROR: NoPage: Page [[commons:File:Wdwdbot]] doesn't exist.
Page [[commons:File:Wdwdbot]] doesn't exist.

which looks ugly. The corresponding template looks like {{NowCommons|transferby=wdwdbot}}. I guess that transferby is misinterpreted by the bot.

Details

Event Timeline

Xqt triaged this task as Medium priority.Apr 10 2016, 4:47 PM

Change 282619 had a related patch set uploaded (by Xqt):
[WIP] Cleanup code

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

I (operator of wdwdbot) add this argument (transferby=wdwdbot) to the template to simple distinguish transfers done by my script from other commonstransfer. This "transferby" parameter is currently unused in the :de:template:Nowcommons.

This parameter should not interfere with other scripts and it is safe to ignore: A filename as first parameter starts after the "|" ether with the "|filename.ext" (without a "=") or a number as parameter, eg. "|1=filename.ext" for the first parameter. A parameter can also start with a specific name eg "|Dateiname=filename.ext".

When a bot script process a wiki source template with possible parameters it is more secure to check for the possiblity of parameter names, recognisable by the "=" and to ignore all parameters which could not be handled, for example this "|transferby=..."

Of cource i can remove adding this parameter. But this will not ensure a correct parameter handling of templates in the processing module.

Dvorapa renamed this task from nocommons.py fails with misleading error to nowcommons.py fails with misleading error.Jul 15 2018, 4:58 PM
Dvorapa updated the task description. (Show Details)
Xqt removed Xqt as the assignee of this task.Apr 3 2020, 2:30 PM