Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix junos unicode errors. #63046

Merged
merged 1 commit into from
Oct 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/ansible/module_utils/network/junos/facts/legacy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ansible.module_utils.network.common.netconf import exec_rpc
from ansible.module_utils.network.junos.junos import get_param, tostring
from ansible.module_utils.network.junos.junos import get_configuration, get_capabilities
from ansible.module_utils._text import to_native
from ansible.module_utils._text import to_text


try:
Expand Down Expand Up @@ -44,14 +44,14 @@ def cli(self, command):
output = reply.find('.//output')
if not output:
self.module.fail_json(msg='failed to retrieve facts for command %s' % command)
return str(output.text).strip()
return to_text(output.text).strip()

def rpc(self, rpc):
return exec_rpc(self.module, tostring(Element(rpc)))

def get_text(self, ele, tag):
try:
return str(ele.find(tag).text).strip()
return to_text(ele.find(tag).text).strip()
except AttributeError:
pass

Expand Down Expand Up @@ -204,7 +204,7 @@ def _connect(self, module):
device.open()
device.timeout = get_param(module, 'timeout') or 10
except ConnectError as exc:
module.fail_json('unable to connect to %s: %s' % (host, to_native(exc)))
module.fail_json('unable to connect to %s: %s' % (host, to_text(exc)))

return device

Expand Down