-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
buf = u""
while not buf.endswith((u":~# ", u":~$ ", u"~]$ ", u"~]# ")):
try:
- chunk = chan.recv(self.__MAX_RECV_BUF)
- if not chunk:
+ s_out = chan.recv(self.__MAX_RECV_BUF)
+ if not s_out:
break
- buf += chunk
+ buf += s_out.decode(encoding=u'utf-8', errors=u'ignore') \
+ if isinstance(s_out, bytes) else s_out
if chan.exit_status_ready():
logger.error(u"Channel exit status ready")
break
buf = u""
while not buf.endswith(prompt):
try:
- chunk = chan.recv(self.__MAX_RECV_BUF)
- if not chunk:
+ s_out = chan.recv(self.__MAX_RECV_BUF)
+ if not s_out:
break
- buf += chunk
+ buf += s_out.decode(encoding=u'utf-8', errors=u'ignore') \
+ if isinstance(s_out, bytes) else s_out
if chan.exit_status_ready():
logger.error(u"Channel exit status ready")
break