Fix lastpass lookup error

Fixes #42062.
This commit is contained in:
Arne Jørgensen 2018-12-19 17:58:06 +01:00 committed by Toshio Kuratomi
parent 189fcb37f9
commit 15fb9d3bc0

View file

@ -38,6 +38,7 @@ RETURN = """
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.module_utils._text import to_bytes, to_text
from ansible.plugins.lookup import LookupBase from ansible.plugins.lookup import LookupBase
@ -61,11 +62,11 @@ class LPass(object):
def _run(self, args, stdin=None, expected_rc=0): def _run(self, args, stdin=None, expected_rc=0):
p = Popen([self.cli_path] + args, stdout=PIPE, stderr=PIPE, stdin=PIPE) p = Popen([self.cli_path] + args, stdout=PIPE, stderr=PIPE, stdin=PIPE)
out, err = p.communicate(stdin) out, err = p.communicate(to_bytes(stdin))
rc = p.wait() rc = p.wait()
if rc != expected_rc: if rc != expected_rc:
raise LPassException(err) raise LPassException(err)
return out, err return to_text(out, errors='surrogate_or_strict'), to_text(err, errors='surrogate_or_strict')
def _build_args(self, command, args=None): def _build_args(self, command, args=None):
if args is None: if args is None: