mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
make sure not to send invalid information
Localectl outputs n/a sometimes when stuff is not set, instead of just not outputting anything. Actually put None in the variable when parsing it, and do not add it to the localectl set command.
This commit is contained in:
parent
428e915d6a
commit
9075070573
1 changed files with 2 additions and 2 deletions
|
@ -87,7 +87,7 @@ def _localectl_status():
|
|||
ret[ctl_key] = {}
|
||||
ret[ctl_key][loc_set[0]] = loc_set[1]
|
||||
else:
|
||||
ret[ctl_key] = {'data': ctl_data}
|
||||
ret[ctl_key] = {'data': None if ctl_data == 'n/a' else ctl_data}
|
||||
if not ret:
|
||||
log.debug("Unable to find any locale information inside the following data:\n%s", locale_ctl_out)
|
||||
raise CommandExecutionError('Unable to parse result of "localectl"')
|
||||
|
@ -102,7 +102,7 @@ def _localectl_set(locale=''):
|
|||
'''
|
||||
locale_params = _parse_dbus_locale() if dbus is not None else _localectl_status().get('system_locale', {})
|
||||
locale_params['LANG'] = six.text_type(locale)
|
||||
args = ' '.join(['{0}="{1}"'.format(k, v) for k, v in six.iteritems(locale_params)])
|
||||
args = ' '.join(['{0}="{1}"'.format(k, v) for k, v in six.iteritems(locale_params) if v is not None])
|
||||
return not __salt__['cmd.retcode']('localectl set-locale {0}'.format(args), python_shell=False)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue