Fix bug in grains outputter

The grain that sets the locale_info doesn't set it in the correct namespace (at least what everyone else including the tests are expecting). This means you get traces when you do a grains.setval something like:

```
[DEBUG   ] Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/output/__init__.py", line 36, in display_output
    display_data = get_printout(out, opts)(data).rstrip()
  File "/usr/lib/python2.6/site-packages/salt/output/grains.py", line 33, in output
    encoding = grains['locale_info']['defaultencoding']
KeyError: 'locale_info'
```
This commit is contained in:
Thomas Jackson 2014-10-29 13:47:24 -07:00
parent 1996302399
commit 79d56c51d4

View File

@ -1104,20 +1104,21 @@ def locale_info():
defaultencoding
'''
grains = {}
grains['locale_info'] = {}
if 'proxyminion' in __opts__:
return grains
try:
(
grains['defaultlanguage'],
grains['defaultencoding']
grains['locale_info']['defaultlanguage'],
grains['locale_info']['defaultencoding']
) = locale.getdefaultlocale()
except Exception:
# locale.getdefaultlocale can ValueError!! Catch anything else it
# might do, per #2205
grains['defaultlanguage'] = 'unknown'
grains['defaultencoding'] = 'unknown'
grains['locale_info']['defaultlanguage'] = 'unknown'
grains['locale_info']['defaultencoding'] = 'unknown'
return grains