mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -07:00
Move uses of to_bytes, to_text, to_native to use the module_utils version (#17423)
We couldn't copy to_unicode, to_bytes, to_str into module_utils because of licensing. So once created it we had two sets of functions that did the same things but had different implementations. To remedy that, this change removes the ansible.utils.unicode versions of those functions.
This commit is contained in:
parent
7a9395b5e0
commit
4ed88512e4
89 changed files with 759 additions and 894 deletions
|
@ -27,10 +27,11 @@ import time
|
|||
|
||||
from ansible import constants as C
|
||||
from ansible.errors import AnsibleError, AnsibleFileNotFound, AnsibleConnectionFailure
|
||||
from ansible.module_utils._text import to_bytes
|
||||
from ansible.parsing.utils.jsonify import jsonify
|
||||
from ansible.plugins.connection import ConnectionBase
|
||||
from ansible.utils.encrypt import key_for_hostname, keyczar_encrypt, keyczar_decrypt
|
||||
from ansible.utils.unicode import to_bytes
|
||||
|
||||
|
||||
try:
|
||||
from __main__ import display
|
||||
|
@ -211,7 +212,7 @@ class Connection(ConnectionBase):
|
|||
''' transfer a file from local to remote '''
|
||||
display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._play_context.remote_addr)
|
||||
|
||||
in_path = to_bytes(in_path, errors='strict')
|
||||
in_path = to_bytes(in_path, errors='surrogate_or_strict')
|
||||
|
||||
if not os.path.exists(in_path):
|
||||
raise AnsibleFileNotFound("file or module does not exist: %s" % in_path)
|
||||
|
@ -265,7 +266,7 @@ class Connection(ConnectionBase):
|
|||
if self.send_data(data):
|
||||
raise AnsibleError("failed to initiate the file fetch with %s" % self._play_context.remote_addr)
|
||||
|
||||
fh = open(to_bytes(out_path, errors='strict'), "w")
|
||||
fh = open(to_bytes(out_path, errors='surrogate_or_strict'), "w")
|
||||
try:
|
||||
bytes = 0
|
||||
while True:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue