mirror of
https://github.com/ansible-collections/community.routeros.git
synced 2025-07-03 14:54:37 +02:00
Change to_text for to_native (#5)
This commit is contained in:
parent
ed0c7d377e
commit
e5ad772703
1 changed files with 8 additions and 8 deletions
|
@ -30,7 +30,7 @@ from __future__ import absolute_import, division, print_function
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from ansible.module_utils._text import to_text, to_native
|
from ansible.module_utils._text import to_native
|
||||||
from ansible.module_utils.basic import env_fallback
|
from ansible.module_utils.basic import env_fallback
|
||||||
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list, ComplexList
|
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list, ComplexList
|
||||||
from ansible.module_utils.connection import Connection, ConnectionError
|
from ansible.module_utils.connection import Connection, ConnectionError
|
||||||
|
@ -84,9 +84,9 @@ def get_defaults_flag(module):
|
||||||
try:
|
try:
|
||||||
out = connection.get('/system default-configuration print')
|
out = connection.get('/system default-configuration print')
|
||||||
except ConnectionError as exc:
|
except ConnectionError as exc:
|
||||||
module.fail_json(msg=to_text(exc, errors='surrogate_then_replace'))
|
module.fail_json(msg=to_native(exc, errors='surrogate_then_replace'))
|
||||||
|
|
||||||
out = to_text(out, errors='surrogate_then_replace')
|
out = to_native(out, errors='surrogate_then_replace')
|
||||||
|
|
||||||
commands = set()
|
commands = set()
|
||||||
for line in out.splitlines():
|
for line in out.splitlines():
|
||||||
|
@ -110,9 +110,9 @@ def get_config(module, flags=None):
|
||||||
try:
|
try:
|
||||||
out = connection.get_config(flags=flags)
|
out = connection.get_config(flags=flags)
|
||||||
except ConnectionError as exc:
|
except ConnectionError as exc:
|
||||||
module.fail_json(msg=to_text(exc, errors='surrogate_then_replace'))
|
module.fail_json(msg=to_native(exc, errors='surrogate_then_replace'))
|
||||||
|
|
||||||
cfg = to_text(out, errors='surrogate_then_replace').strip()
|
cfg = to_native(out, errors='surrogate_then_replace').strip()
|
||||||
_DEVICE_CONFIGS[flag_str] = cfg
|
_DEVICE_CONFIGS[flag_str] = cfg
|
||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
|
@ -144,13 +144,13 @@ def run_commands(module, commands, check_rc=True):
|
||||||
try:
|
try:
|
||||||
out = connection.get(command, prompt, answer)
|
out = connection.get(command, prompt, answer)
|
||||||
except ConnectionError as exc:
|
except ConnectionError as exc:
|
||||||
module.fail_json(msg=to_text(exc, errors='surrogate_then_replace'))
|
module.fail_json(msg=to_native(exc, errors='surrogate_then_replace'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
out = to_text(out, errors='surrogate_or_strict')
|
out = to_native(out, errors='surrogate_or_strict')
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg=u'Failed to decode output from %s: %s' % (cmd, to_text(out)))
|
msg=u'Failed to decode output from %s: %s' % (cmd, to_native(out)))
|
||||||
|
|
||||||
responses.append(out)
|
responses.append(out)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue