Fix bug in locale setting that breaks logParser running in CI
Description of bug
After !1764 (merged) all logParser jobs have been broken, check e.g. https://gitlab.cern.ch/atlas-physics/pmg/mcjoboptions/-/jobs/21222934 or see #167 (closed)
This is because "en_us" is not available in the docker image that we use. I tried to make this more flexible although I am not sure this will work on every system. If it breaks again I would suggest that we revert completely !1764 (merged), for now this fix should work in the CI, lxplus (and I've also tested on my mac).
Changes introduced
Take the language from the output of the LC_CTYPE
command and if LC_CTYPE
is not set, assume that "C" locale exists and set LC_CTYPE
to C.UTF-8
(which exists in the docker image)
Tests
In the docker image
root@5d8f62124105:/mcjoboptions# python scripts/logParser.py -i 100xxx/100000/log.generate >&/dev/null ; echo $?
0
while before the fix it gave
root@5d8f62124105:/mcjoboptions# python scripts/logParser.py -i 100xxx/100000/log.generate
Traceback (most recent call last):
File "scripts/logParser.py", line 8, in <module>
locale.setlocale(locale.LC_CTYPE, f'{lang}.UTF-8')
File "/usr/local/lib/python3.6/locale.py", line 598, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
Issues resolved
Closes #167 (closed)