locale addon: fix call of localedef

- Set stdin to /dev/null to fix error on Generic (GBM)
  CompletedProcess(args=['/storage/.kodi/addons/service.locale/bin/localedef', '-v', '-f', 'UTF-8', '-i', 'de_DE', '/storage/.kodi/addons/service.locale/locpath/de_DE.UTF-8'], returncode=4, stdout=b'', stderr=b"gzip: invalid magic\ngzip: invalid magic\n[error] character map file `UTF-8' not found: No such file or directory\n[warning] LC_NAME: field `name_gen' not defined\n[warning] LC_ADDRESS: field `country_post' not defined\n[warning] LC_ADDRESS: field `country_isbn' not defined\n[warning] LC_IDENTIFICATION: field `audience' not defined\n[warning] LC_IDENTIFICATION: field `application' not defined\n[warning] LC_IDENTIFICATION: field `abbreviation' not defined\n[error] no output file produced because errors were issued\n"

- Add error detection code
This commit is contained in:
mglae 2022-08-13 19:55:14 +02:00
parent 459874e831
commit 6644f74963
2 changed files with 18 additions and 2 deletions

View File

@ -38,8 +38,20 @@ class Monitor(xbmc.Monitor):
if os.path.isdir(localepath) == False:
os.environ['I18NPATH'] = i18npath
subprocess.call([os.path.join(path, 'bin/localedef'), '-f', charmap,
'-i', locale, localepath])
rc = subprocess.run([os.path.join(path, 'bin/localedef'), '-v', '-f', charmap,
'-i', locale, localepath], capture_output=True,
stdin=subprocess.DEVNULL)
if rc.returncode not in [0, 1]:
xbmc.log(repr(rc), xbmc.LOGERROR)
try:
os.rmdir(localepath)
except OSError as e:
pass
if os.path.isfile(profile):
os.unlink(profile)
xbmcgui.Dialog().ok('Locale', strings(30004).format(lang))
return
if os.path.isdir(profiled) == False:
os.makedirs(profiled)

View File

@ -17,3 +17,7 @@ msgstr ""
msgctxt "#30003"
msgid "Locale changed to {}. Please reboot to apply globally."
msgstr ""
msgctxt "#30004"
msgid "Creating locale {} failed. Aborting."
msgstr ""