Makes $PIPE and $FILE macros accept utf-8 input

pull/2590/head
Sébastien Bocahu 12 years ago
parent 20ec682b30
commit b94bf051d5

@ -17,6 +17,7 @@
from ansible import utils, errors
import os
import codecs
class LookupModule(object):
@ -31,5 +32,5 @@ class LookupModule(object):
path = utils.path_dwim(self.basedir, term)
if not os.path.exists(path):
raise errors.AnsibleError("%s does not exist" % path)
ret.append(open(path).read().rstrip())
ret.append(codecs.open(path, encoding="utf8").read().rstrip())
return ret

@ -31,7 +31,7 @@ class LookupModule(object):
p = subprocess.Popen(term, cwd=self.basedir, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
(stdout, stderr) = p.communicate()
if p.returncode == 0:
ret.append(stdout.rstrip())
ret.append(stdout.decode("utf-8").rstrip())
else:
raise errors.AnsibleError("lookup_plugin.pipe(%s) returned %d" % (term, p.returncode))
return ret

@ -176,7 +176,7 @@ def _varFind(basedir, text, vars, lookup_fatal, depth, expand_lists):
try:
replacement = instance.run(args, inject=vars)
if expand_lists:
replacement = ",".join([str(x) for x in replacement])
replacement = ",".join([unicode(x) for x in replacement])
except:
if not lookup_fatal:
replacement = None

Loading…
Cancel
Save