[PR #8517/5259caac backport][stable-9] cmd_runner - handle special value "auto" in param force_lang (#8581)

cmd_runner - handle special value "auto" in param force_lang (#8517)

* cmd_runner - handle special value "auto" in param force_lang

* add changelog frag

* update doc in puppet

* fix markup

(cherry picked from commit 5259caacae)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2024-07-05 08:54:04 +02:00 committed by GitHub
parent 3a01ceb355
commit c16c4a32d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View file

@ -11,6 +11,7 @@ from functools import wraps
from ansible.module_utils.common.collections import is_sequence
from ansible.module_utils.six import iteritems
from ansible.module_utils.common.locale import get_best_parsable_locale
def _ensure_list(value):
@ -236,7 +237,13 @@ class CmdRunner(object):
fmt = _Format.as_func(func=fmt, ignore_none=True)
self.arg_formats[fmt_name] = fmt
self.check_rc = check_rc
self.force_lang = force_lang
if force_lang == "auto":
try:
self.force_lang = get_best_parsable_locale()
except RuntimeWarning:
self.force_lang = "C"
else:
self.force_lang = force_lang
self.path_prefix = path_prefix
if environ_update is None:
environ_update = {}