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

Assorted python3 fixes for network code. #18777

Merged
merged 1 commit into from
Dec 15, 2016
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions lib/ansible/module_utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

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 = [
Expand Down Expand Up @@ -132,23 +132,23 @@ def alarm_handler(self, signum, frame):
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()
Expand Down
4 changes: 2 additions & 2 deletions lib/ansible/plugins/action/net_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
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('__.+__')
Expand Down Expand Up @@ -87,7 +87,7 @@ def _handle_template(self):
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)
Expand Down