mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Fix several things causing tracebacks with unicode cwd (#27731)
Fixes #27511
This commit is contained in:
parent
181b31e282
commit
3f12fccd02
4 changed files with 6 additions and 6 deletions
|
@ -161,7 +161,7 @@ class CLI(with_metaclass(ABCMeta, object)):
|
||||||
running an Ansible command.
|
running an Ansible command.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
display.vv(self.parser.get_version())
|
display.vv(to_text(self.parser.get_version()))
|
||||||
|
|
||||||
if C.CONFIG_FILE:
|
if C.CONFIG_FILE:
|
||||||
display.v(u"Using %s as config file" % to_text(C.CONFIG_FILE))
|
display.v(u"Using %s as config file" % to_text(C.CONFIG_FILE))
|
||||||
|
|
|
@ -35,7 +35,7 @@ __metaclass__ = type
|
||||||
import os
|
import os
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible.errors import AnsibleParserError
|
from ansible.errors import AnsibleParserError
|
||||||
from ansible.module_utils._text import to_bytes, to_text
|
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||||
from ansible.plugins.vars import BaseVarsPlugin
|
from ansible.plugins.vars import BaseVarsPlugin
|
||||||
from ansible.inventory.host import Host
|
from ansible.inventory.host import Host
|
||||||
from ansible.inventory.group import Group
|
from ansible.inventory.group import Group
|
||||||
|
@ -87,7 +87,7 @@ class VarsModule(BaseVarsPlugin):
|
||||||
data = combine_vars(data, new_data)
|
data = combine_vars(data, new_data)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AnsibleParserError(to_text(e))
|
raise AnsibleParserError(to_native(e))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _find_vars_files(self, path, name):
|
def _find_vars_files(self, path, name):
|
||||||
|
|
|
@ -90,7 +90,7 @@ def stringc(text, color):
|
||||||
|
|
||||||
if ANSIBLE_COLOR:
|
if ANSIBLE_COLOR:
|
||||||
color_code = parsecolor(color)
|
color_code = parsecolor(color)
|
||||||
return "\n".join([u"\033[%sm%s\033[0m" % (color_code, t) for t in text.split('\n')])
|
return u"\n".join([u"\033[%sm%s\033[0m" % (color_code, t) for t in text.split(u'\n')])
|
||||||
else:
|
else:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ def makedirs_safe(path, mode=None):
|
||||||
|
|
||||||
def basedir(source):
|
def basedir(source):
|
||||||
""" returns directory for inventory or playbook """
|
""" returns directory for inventory or playbook """
|
||||||
|
source = to_bytes(source, errors='surrogate_or_strict')
|
||||||
dname = None
|
dname = None
|
||||||
if os.path.isdir(source):
|
if os.path.isdir(source):
|
||||||
dname = source
|
dname = source
|
||||||
|
@ -88,4 +88,4 @@ def basedir(source):
|
||||||
# don't follow symlinks for basedir, enables source re-use
|
# don't follow symlinks for basedir, enables source re-use
|
||||||
dname = os.path.abspath(dname)
|
dname = os.path.abspath(dname)
|
||||||
|
|
||||||
return dname
|
return to_text(dname, errors='surrogate_or_strict')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue