summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Case <this.is@nathanielca.se>2016-12-15 16:25:03 -0500
committerGitHub <noreply@github.com>2016-12-15 16:25:03 -0500
commit7900319fc35fd9cd68d54eb6c9518678eb5f5714 (patch)
tree5bd86249d222cf32cbcd9d2ffc2bd4f02cc84894
parentc49eac5645e6978eeab87501bb23dfe55873123e (diff)
downloadansible-7900319fc35fd9cd68d54eb6c9518678eb5f5714.tar.gz
Assorted python3 fixes for network code. (#18777)
-rw-r--r--lib/ansible/module_utils/shell.py10
-rw-r--r--lib/ansible/plugins/action/net_config.py4
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/ansible/module_utils/shell.py b/lib/ansible/module_utils/shell.py
index 0dbc0c64af..0404fd1348 100644
--- a/lib/ansible/module_utils/shell.py
+++ b/lib/ansible/module_utils/shell.py
@@ -31,7 +31,7 @@ except ImportError:
from ansible.module_utils.basic import get_exception
from ansible.module_utils.network import NetworkError
-from ansible.module_utils.six.moves import StringIO
+from ansible.module_utils.six import BytesIO
from ansible.module_utils._text import to_native
ANSI_RE = [
@@ -132,23 +132,23 @@ class Shell(object):
raise ShellError('timeout trying to send command: %s' % self._history[-1])
def receive(self, cmd=None):
- recv = StringIO()
+ recv = BytesIO()
handled = False
while True:
data = self.shell.recv(200)
recv.write(data)
- recv.seek(recv.tell() - 200)
+ recv.seek(recv.tell() - len(data))
- window = self.strip(recv.read())
+ window = self.strip(recv.read().decode('utf8'))
if hasattr(cmd, 'prompt') and not handled:
handled = self.handle_prompt(window, cmd)
try:
if self.find_prompt(window):
- resp = self.strip(recv.getvalue())
+ resp = self.strip(recv.getvalue().decode('utf8'))
return self.sanitize(cmd, resp)
except ShellError:
exc = get_exception()
diff --git a/lib/ansible/plugins/action/net_config.py b/lib/ansible/plugins/action/net_config.py
index d36f09a65f..47d422be12 100644
--- a/lib/ansible/plugins/action/net_config.py
+++ b/lib/ansible/plugins/action/net_config.py
@@ -23,10 +23,10 @@ import os
import re
import time
import glob
-import urlparse
from ansible.plugins.action import ActionBase
from ansible.module_utils._text import to_text
+from ansible.module_utils.six.moves.urllib.parse import urlsplit
PRIVATE_KEYS_RE = re.compile('__.+__')
@@ -87,7 +87,7 @@ class ActionModule(ActionBase):
src = self._task.args.get('src')
working_path = self._get_working_path()
- if os.path.isabs(src) or urlparse.urlsplit('src').scheme:
+ if os.path.isabs(src) or urlsplit('src').scheme:
source = src
else:
source = self._loader.path_dwim_relative(working_path, 'templates', src)