Page MenuHomePhabricator

Pywikibot: touch.py crashes when run with default parameters (uncaught exception <class 'pywikibot.i18n.TranslationError'>)
Closed, ResolvedPublicBUG REPORT

Description

Steps to Reproduce:

Run touch.py with default parameters using the following command:

python pwb.py touch.py -lang:ar -cat:"تحويلات متصلة بعنصر ويكي بيانات"

(In this case, it will run on this category: ar:تصنيف:تحويلات متصلة بعنصر ويكي بيانات)

Actual Results:

The script crashes with the following traceback:

python pwb.py touch.py -lang:ar -cat:"تحويلات متصلة بعنصر ويكي بيانات"
Retrieving 50 pages from wikipedia:ar.

0 pages read
0 pages written
Execution time: 11 seconds
Script terminated by exception:

ERROR: TranslationError: No English translation has been defined for TranslateWiki key
"pywikibot-touch". It can happen due to lack of i18n submodule or
files or an outdated submodule. See
https://www.mediawiki.org/wiki/Manual:Pywikibot/i18n
Traceback (most recent call last):
  File "pwb.py", line 250, in <module>
    if not main():
  File "pwb.py", line 243, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "pwb.py", line 95, in run_python_file
    main_mod.__dict__)
  File "./scripts/touch.py", line 135, in <module>
    main()
  File "./scripts/touch.py", line 127, in main
    bot.run()
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/bot.py", line 1702, in run
    super(MultipleSitesBot, self).run()
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/bot.py", line 1505, in run
    self.treat(page)
  File "./scripts/touch.py", line 60, in treat
    page.touch(botflag=self.getOption('botflag'))
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/page.py", line 1425, in touch
    summary = i18n.twtranslate(self.site, 'pywikibot-touch')
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/tools/__init__.py", line 1738, in wrapper
    return obj(*__args, **__kw)
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/i18n.py", line 756, in twtranslate
    twtitle, __url__)))
pywikibot.i18n.TranslationError: No English translation has been defined for TranslateWiki key
"pywikibot-touch". It can happen due to lack of i18n submodule or
files or an outdated submodule. See
https://www.mediawiki.org/wiki/Manual:Pywikibot/i18n
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.i18n.TranslationError'>

Notes

Running the with the following command works as expected:

python pwb.py touch.py -purge -lang:ar -cat:"تحويلات متصلة بعنصر ويكي بيانات"

So, the issue is only when running the script without the

-purge

Expected Results:

  • The script should not crash when run with default parameters.
  • If the intention of the developers is to force the users to always use -purge, then in this case the script should give a Too few input arguments error or something like that, but I don't believe that crashing the script is the correct behavior here. Thank you.

Event Timeline

Do you have up-to-date pywikibot and pywikibot-i18n? This was solved in January!

Do you have up-to-date pywikibot and pywikibot-i18n? This was solved in January!

Thank you for your comment. This is what I get when running git pull followed by version.py (I removed some information for privacy.) I run the bot on the Toolforge as many other bot operaters.

git pull
Already up-to-date.
python pwb.py version.py
Pywikibot: [https] r-pywikibot-core.git (b96a9bd, g11047, 2019/05/11, 16:42:57, ok)
Release version: 3.1.dev0
requests version: 2.12.4
  cacerts: /etc/ssl/certs/ca-certificates.crt
    certificate test: ok
Python: 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516]
Toolforge hostname: tools-sgebastion-07
PYWIKIBOT_DIR: Not set
PYWIKIBOT_DIR_PWB:
PYWIKIBOT_NO_USER_CONFIG: Not set
Config base dir: /mnt/nfs/labstore-secondary-tools-home/meno25/core

Try git pull --recurse-submodules

Try git pull --recurse-submodules

Done and this is the output

git pull --recurse-submodules
Fetching submodule scripts/i18n
From https://gerrit.wikimedia.org/r/pywikibot/i18n
   81607ff2..e9f472c7  master     -> origin/master
Already up-to-date.

Did it help to solve the issue for you?

Yeah, you should always do git pull --all or git pull --recurse-submodules to update also the contents of the i18n folder. It looks you had it out-of-date: from December.

And we should list i18n in the version.py too

This comment was removed by Meno25.
This comment was removed by Dvorapa.

Did it help to solve the issue for you?

No, sir. This is the output after running git pull --all and git pull --recurse-submodules

python pwb.py touch.py -lang:ar -cat:"تحويلات متصلة بعنصر ويكي بيانات"
Retrieving 50 pages from wikipedia:ar.

0 pages read
0 pages written
Execution time: 11 seconds
Script terminated by exception:

ERROR: TranslationError: No English translation has been defined for TranslateWiki key
"pywikibot-touch". It can happen due to lack of i18n submodule or
files or an outdated submodule. See
https://www.mediawiki.org/wiki/Manual:Pywikibot/i18n
Traceback (most recent call last):
  File "pwb.py", line 250, in <module>
    if not main():
  File "pwb.py", line 243, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "pwb.py", line 95, in run_python_file
    main_mod.__dict__)
  File "./scripts/touch.py", line 135, in <module>
    main()
  File "./scripts/touch.py", line 127, in main
    bot.run()
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/bot.py", line 1702, in run
    super(MultipleSitesBot, self).run()
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/bot.py", line 1505, in run
    self.treat(page)
  File "./scripts/touch.py", line 60, in treat
    page.touch(botflag=self.getOption('botflag'))
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/page.py", line 1425, in touch
    summary = i18n.twtranslate(self.site, 'pywikibot-touch')
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/tools/__init__.py", line 1738, in wrapper
    return obj(*__args, **__kw)
  File "/mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/i18n.py", line 756, in twtranslate
    twtitle, __url__)))
pywikibot.i18n.TranslationError: No English translation has been defined for TranslateWiki key
"pywikibot-touch". It can happen due to lack of i18n submodule or
files or an outdated submodule. See
https://www.mediawiki.org/wiki/Manual:Pywikibot/i18n
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.i18n.TranslationError'>

What is the contents of your scripts/i18n/pywikibot/en.json file (or ar.json file if present)?

What is the contents of your scripts/i18n/pywikibot/en.json file (or ar.json file if present)?

Content of en.json is

{
	"@metadata": {
		"authors": [
			"Daniel Herding",
			"Huji",
			"Siebrand",
			"Revi"
		]
	},
	"pywikibot-enter-category-name": "Please enter the category name:",
	"pywikibot-enter-file-links-processing": "Links to which file page should be processed?",
	"pywikibot-enter-finished-browser": "Press Enter when finished in browser.",
	"pywikibot-enter-namespace-number": "Please enter a namespace by its number:",
	"pywikibot-enter-new-text": "Please enter the new text:",
	"pywikibot-enter-page-processing": "Which page should be processed?",
	"pywikibot-enter-xml-filename": "Please enter the XML dump's filename:",
	"pywikibot-fixes-fckeditor": "Bot: Fixing rich-editor html",
	"pywikibot-fixes-html": "Bot: Converting/fixing HTML",
	"pywikibot-fixes-syntax": "Bot: Fixing wiki syntax"
}

ar.json is

{
	"@metadata": {
		"authors": [
			"Meno25",
			"TTMTT",
			"Zanatos",
			"ديفيد"
		]
	},
	"pywikibot-enter-category-name": "فضلا أدخل اسم التصنيف:",
	"pywikibot-enter-file-links-processing": "الوصلات لأي صفحة ملف ينبغي أن تتم معالجتها؟",
	"pywikibot-enter-finished-browser": "اضغط Enter عند الانتهاء في المتصفح.",
	"pywikibot-enter-namespace-number": "الرجاء إدخال نطاق برقمه:",
	"pywikibot-enter-new-text": "فضلاً أدخل النص الجديد:",
	"pywikibot-enter-page-processing": "الصفحة التي تنبغي معالجتها؟",
	"pywikibot-enter-xml-filename": "الرجاء إدخال اسم ملف تفريغ XML:",
	"pywikibot-fixes-fckeditor": "بوت: تصحيح rich-editor html",
	"pywikibot-fixes-html": "بوت: تحويل/تصليح HTML",
	"pywikibot-fixes-syntax": "بوت: تصليح تهيئة الويكي"
}

Weird, this looks like it is not up-to-date even after git pull --all, see the current file in repository: https://phabricator.wikimedia.org/diffusion/PWIN/browse/master/pywikibot/en.json

Please try to remove scripts/i18n folder and then git submodule update for Pywikibot. Finally this should work.

Or you can clone the whole Pywikibot folder again cleanly if you want

Weird, this looks like it is not up-to-date even after git pull --all, see the current file in repository: https://phabricator.wikimedia.org/diffusion/PWIN/browse/master/pywikibot/en.json

Please try to remove scripts/i18n folder and then git submodule update for Pywikibot. Finally this should work.

Or you can clone the whole Pywikibot folder again cleanly if you want

Thank you, This solved it for me. The script now works as expected. Many thanks for both your efforts. This is the output:

git submodule update
Submodule path 'scripts/i18n': checked out 'e9f472c7db9c88260fe10cc4918cb786e586857e'
python pwb.py touch.py -lang:ar -cat:"تحويلات متصلة بعنصر ويكي بيانات"
Retrieving 50 pages from wikipedia:ar.
Page [[331 (عدد)]] saved
Sleeping for 4.7 seconds, 2019-05-12 20:04:11
Page [[332 (عدد)]] saved
Sleeping for 4.7 seconds, 2019-05-12 20:04:16
Page [[333 (عدد)]] saved
Sleeping for 4.7 seconds, 2019-05-12 20:04:21
Page [[334 (عدد)]] saved
Sleeping for 4.6 seconds, 2019-05-12 20:04:26
Page [[335 (عدد)]] saved
Sleeping for 4.8 seconds, 2019-05-12 20:04:31
Page [[336 (عدد)]] saved
Sleeping for 4.7 seconds, 2019-05-12 20:04:36
Page [[337 (عدد)]] saved
Sleeping for 4.7 seconds, 2019-05-12 20:04:41
Page [[338 (عدد)]] saved
Sleeping for 4.7 seconds, 2019-05-12 20:04:46
Page [[339 (عدد)]] saved
Sleeping for 4.7 seconds, 2019-05-12 20:04:51
Page [[340 (عدد)]] saved
Sleeping for 4.7 seconds, 2019-05-12 20:04:56
Meno25 assigned this task to Dvorapa.