mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Salt Unicode Update 3rd tier 3rd bunch from DK
This commit is contained in:
parent
af7a29f75a
commit
9b09d1b2c9
@ -4,7 +4,7 @@ Module for managing container and VM images
|
||||
|
||||
.. versionadded:: 2014.7.0
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
@ -21,6 +21,7 @@ import salt.syspaths
|
||||
import salt.utils.kickstart
|
||||
import salt.utils.path
|
||||
import salt.utils.preseed
|
||||
import salt.utils.stringutils
|
||||
import salt.utils.validate.path
|
||||
import salt.utils.yast
|
||||
from salt.exceptions import SaltInvocationError
|
||||
@ -155,7 +156,7 @@ def bootstrap(
|
||||
try:
|
||||
__salt__['file.mkdir'](root)
|
||||
except Exception as exc:
|
||||
return {'Error': pprint.pformat(exc)}
|
||||
return {'Error': salt.utils.stringutils.to_unicode(pprint.pformat(exc))}
|
||||
elif img_format == 'sparse':
|
||||
if not img_size:
|
||||
raise SaltInvocationError('An img_size must be specified for a sparse file')
|
||||
@ -170,7 +171,7 @@ def bootstrap(
|
||||
__salt__['cmd.run']('losetup {0} {1}'.format(loop1, root))
|
||||
loop2 = __salt__['cmd.run']('losetup -f')
|
||||
log.debug('Second loop device is {0}'.format(loop2))
|
||||
start = str(2048 * 2048)
|
||||
start = six.text_type(2048 * 2048)
|
||||
__salt__['cmd.run']('losetup -o {0} {1} {2}'.format(start, loop2, loop1))
|
||||
__salt__['mount.mount'](mount_dir, loop2)
|
||||
|
||||
@ -234,7 +235,7 @@ def _mkpart(root, fs_format, fs_opts, mount_dir):
|
||||
log.debug('First loop device is {0}'.format(loop1))
|
||||
__salt__['cmd.run']('losetup {0} {1}'.format(loop1, root))
|
||||
part_info = __salt__['partition.list'](loop1)
|
||||
start = str(2048 * 2048) + 'B'
|
||||
start = six.text_type(2048 * 2048) + 'B'
|
||||
end = part_info['info']['size']
|
||||
__salt__['partition.mkpart'](loop1, 'primary', start=start, end=end)
|
||||
__salt__['partition.set'](loop1, '1', 'boot', 'on')
|
||||
@ -623,7 +624,7 @@ def _tar(name, root, path=None, compress='bzip2'):
|
||||
try:
|
||||
__salt__['file.mkdir'](path)
|
||||
except Exception as exc:
|
||||
return {'Error': pprint.pformat(exc)}
|
||||
return {'Error': salt.utils.stringutils.to_unicode(pprint.pformat(exc))}
|
||||
|
||||
compression, ext = _compress(compress)
|
||||
|
||||
@ -650,7 +651,7 @@ def _untar(name, dest=None, path=None, compress='bz2'):
|
||||
try:
|
||||
__salt__['file.mkdir'](dest)
|
||||
except Exception as exc:
|
||||
return {'Error': pprint.pformat(exc)}
|
||||
return {'Error': salt.utils.stringutils.to_unicode(pprint.pformat(exc))}
|
||||
|
||||
compression, ext = _compress(compress)
|
||||
|
||||
|
@ -11,7 +11,7 @@ to the correct service manager
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import fnmatch
|
||||
import re
|
||||
|
@ -3,7 +3,7 @@
|
||||
Support for Gentoolkit
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
|
@ -36,7 +36,7 @@ Module for handling openstack glance calls.
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import re
|
||||
|
||||
# Import salt libs
|
||||
@ -309,10 +309,10 @@ def image_delete(id=None, name=None, profile=None): # pylint: disable=C0103
|
||||
'comment': 'No image with ID {0}'.format(id)
|
||||
}
|
||||
except exc.HTTPForbidden as forbidden:
|
||||
log.error(str(forbidden))
|
||||
log.error(six.text_type(forbidden))
|
||||
return {
|
||||
'result': False,
|
||||
'comment': str(forbidden)
|
||||
'comment': six.text_type(forbidden)
|
||||
}
|
||||
return {
|
||||
'result': True,
|
||||
|
@ -4,7 +4,7 @@ Module for working with the Glassfish/Payara 4.x management API
|
||||
.. versionadded:: Carbon
|
||||
:depends: requests
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
try: # python2
|
||||
from urllib import quote, unquote
|
||||
|
@ -4,7 +4,7 @@ GNOME implementations
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import re
|
||||
import logging
|
||||
try:
|
||||
@ -13,6 +13,9 @@ try:
|
||||
except ImportError:
|
||||
HAS_PWD = False
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
|
||||
# Import 3rd-party libs
|
||||
try:
|
||||
from gi.repository import Gio, GLib # pylint: disable=W0611
|
||||
@ -90,7 +93,8 @@ class _GSettings(object):
|
||||
result['stdout'] = 'User {0} does not exist'.format(user)
|
||||
return result
|
||||
|
||||
cmd = 'dbus-launch --exit-with-session gsettings set {0} {1} "{2}"'.format(self.SCHEMA, self.KEY, str(value))
|
||||
cmd = 'dbus-launch --exit-with-session gsettings set {0} {1} "{2}"'.format(
|
||||
self.SCHEMA, self.KEY, six.text_type(value))
|
||||
environ = {}
|
||||
environ['XDG_RUNTIME_DIR'] = '/run/user/{0}'.format(uid)
|
||||
result = __salt__['cmd.run_all'](cmd, runas=user, env=environ, python_shell=False)
|
||||
|
@ -20,7 +20,7 @@ Module for working with the Grafana v4 API
|
||||
grafana_password: admin
|
||||
grafana_timeout: 3
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
try:
|
||||
import requests
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Support for GRUB Legacy
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
@ -70,6 +70,7 @@ def conf():
|
||||
try:
|
||||
with salt.utils.files.fopen(_detect_conf(), 'r') as _fp:
|
||||
for line in _fp:
|
||||
line = salt.utils.stringutils.to_unicode(line)
|
||||
if line.startswith('#'):
|
||||
continue
|
||||
if line.startswith('\n'):
|
||||
@ -102,7 +103,7 @@ def conf():
|
||||
stanzas.append(stanza)
|
||||
except (IOError, OSError) as exc:
|
||||
msg = "Could not read grub config: {0}"
|
||||
raise CommandExecutionError(msg.format(str(exc)))
|
||||
raise CommandExecutionError(msg.format(six.text_type(exc)))
|
||||
|
||||
ret['stanzas'] = []
|
||||
for stanza in stanzas:
|
||||
|
@ -4,7 +4,7 @@ Managing Images in OpenStack Glance
|
||||
===================================
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import time
|
||||
|
||||
|
@ -14,7 +14,7 @@ You can setup connection parameters like this
|
||||
- user: admin
|
||||
- password: changeit
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
try:
|
||||
import salt.utils.json
|
||||
@ -43,7 +43,7 @@ def _json_to_unicode(data):
|
||||
if isinstance(value, dict):
|
||||
ret[key] = _json_to_unicode(value)
|
||||
else:
|
||||
ret[key] = six.u(str(value).lower())
|
||||
ret[key] = six.text_type(value).lower()
|
||||
else:
|
||||
ret[key] = value
|
||||
return ret
|
||||
@ -56,13 +56,14 @@ def _is_updated(old_conf, new_conf):
|
||||
changed = {}
|
||||
|
||||
# Dirty json hacking to get parameters in the same format
|
||||
new_conf = _json_to_unicode(salt.utils.json.loads(salt.utils.json.dumps(new_conf, ensure_ascii=False)))
|
||||
new_conf = _json_to_unicode(salt.utils.json.loads(
|
||||
salt.utils.json.dumps(new_conf, ensure_ascii=False)))
|
||||
old_conf = salt.utils.json.loads(salt.utils.json.dumps(old_conf, ensure_ascii=False))
|
||||
|
||||
for key, value in old_conf.items():
|
||||
oldval = str(value).lower()
|
||||
oldval = six.text_type(value).lower()
|
||||
if key in new_conf:
|
||||
newval = str(new_conf[key]).lower()
|
||||
newval = six.text_type(new_conf[key]).lower()
|
||||
if oldval == 'null' or oldval == 'none':
|
||||
oldval = ''
|
||||
if key in new_conf and newval != oldval:
|
||||
|
@ -24,7 +24,7 @@ Control the GNOME settings
|
||||
- clock_show_date: true
|
||||
- clock_format: 12h
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
# Import python libs
|
||||
import logging
|
||||
import re
|
||||
@ -40,7 +40,7 @@ def _check_current_value(gnome_kwargs, value):
|
||||
Check the current value with the passed value
|
||||
'''
|
||||
current_value = __salt__['gnome.get'](**gnome_kwargs)
|
||||
return str(current_value) == str(value)
|
||||
return six.text_type(current_value) == six.text_type(value)
|
||||
|
||||
|
||||
def _do(name, gnome_kwargs, preferences):
|
||||
@ -64,7 +64,7 @@ def _do(name, gnome_kwargs, preferences):
|
||||
|
||||
# need to convert boolean values to strings and make lowercase to
|
||||
# pass to gsettings
|
||||
value = str(value).lower()
|
||||
value = six.text_type(value).lower()
|
||||
|
||||
elif isinstance(value, int):
|
||||
ftype = 'int'
|
||||
|
@ -167,7 +167,7 @@ they exist in dashboards. The module will not manage rows that are not defined,
|
||||
allowing users to manage their own custom rows.
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import copy
|
||||
|
||||
# Import Salt libs
|
||||
@ -343,10 +343,10 @@ def dashboard_present(
|
||||
ret['comment'] = msg
|
||||
return ret
|
||||
body = {
|
||||
"user": "guest",
|
||||
"group": "guest",
|
||||
"title": name,
|
||||
"dashboard": salt.utils.json.dumps(_dashboard)
|
||||
'user': 'guest',
|
||||
'group': 'guest',
|
||||
'title': name,
|
||||
'dashboard': salt.utils.json.dumps(_dashboard)
|
||||
}
|
||||
updated = __salt__['elasticsearch.index'](
|
||||
index=index, doc_type='dashboard', body=body, id=name,
|
||||
|
@ -39,7 +39,7 @@ allowing users to manage their own custom rows.
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import copy
|
||||
|
||||
# Import Salt libs
|
||||
|
@ -38,7 +38,7 @@ Basic auth setup
|
||||
- basic_auth_password: mypass
|
||||
- is_default: true
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
from salt.ext.six import string_types
|
||||
from salt.utils.dictdiffer import deep_diff
|
||||
|
@ -40,7 +40,7 @@ Basic auth setup
|
||||
- state: ""
|
||||
- country: ""
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import salt.utils.dictupdate as dictupdate
|
||||
from salt.utils.dictdiffer import deep_diff
|
||||
|
@ -35,7 +35,7 @@ Basic auth setup
|
||||
- fullname: Foo Bar
|
||||
- is_admin: true
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import salt.utils.dictupdate as dictupdate
|
||||
from salt.utils.dictdiffer import deep_diff
|
||||
|
@ -39,7 +39,7 @@ allowing users to manage their own custom rows.
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import copy
|
||||
import requests
|
||||
|
||||
|
@ -24,7 +24,7 @@ Manage Grafana v2.0 data sources
|
||||
- basic_auth_password: mypass
|
||||
- is_default: true
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import requests
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
@ -3,7 +3,7 @@
|
||||
:codeauthor: :email:`Rupesh Tare <rupesht@saltstack.com>`
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
@ -19,6 +19,7 @@ from tests.support.mock import (
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.modules.grub_legacy as grub_legacy
|
||||
import salt.utils.stringutils
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
|
||||
@ -47,7 +48,7 @@ class GrublegacyTestCase(TestCase, LoaderModuleMockMixin):
|
||||
with patch.object(grub_legacy, '_detect_conf', return_value='A'):
|
||||
self.assertRaises(CommandExecutionError, grub_legacy.conf)
|
||||
|
||||
file_data = '\n'.join(['#', 'A B C D,E,F G H'])
|
||||
file_data = salt.utils.stringutils.to_str('\n'.join(['#', 'A B C D,E,F G H']))
|
||||
with patch('salt.utils.files.fopen',
|
||||
mock_open(read_data=file_data), create=True) as f_mock:
|
||||
f_mock.return_value.__iter__.return_value = file_data.splitlines()
|
||||
|
@ -3,7 +3,7 @@
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.unit import skipIf, TestCase
|
||||
|
@ -3,7 +3,7 @@
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
Loading…
Reference in New Issue
Block a user