Line length: Fix recent merges
[csit.git] / resources / libraries / python / ssh.py
index 5359a6e..476cb62 100644 (file)
@@ -1,4 +1,4 @@
-# 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:
@@ -302,10 +302,11 @@ class SSH:
         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
@@ -335,10 +336,11 @@ class SSH:
         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