log results for get_best_parsable_locale (#77319)

* log locale outcomes from function
* also included variant forms of same prefs
pull/77196/merge
Brian Coca 3 years ago committed by GitHub
parent 2e69b5867e
commit 4635c75ef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- get_parsable_locale now logs result when in debug mode.

@ -32,7 +32,7 @@ def get_best_parsable_locale(module, preferences=None, raise_on_locale=False):
if preferences is None:
# new POSIX standard or English cause those are messages core team expects
# yes, the last 2 are the same but some systems are weird
preferences = ['C.utf8', 'en_US.utf8', 'C', 'POSIX']
preferences = ['C.utf8', 'C.UTF-8', 'en_US.utf8', 'en_US.UTF-8', 'C', 'POSIX']
rc, out, err = module.run_command([locale, '-a'])
@ -50,8 +50,12 @@ def get_best_parsable_locale(module, preferences=None, raise_on_locale=False):
found = pref
break
except RuntimeWarning:
except RuntimeWarning as e:
if raise_on_locale:
raise
else:
module.debug('Failed to get locale information: %s' % to_native(e))
module.debug('Matched prefered locale to: %s' % found)
return found

Loading…
Cancel
Save