X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2Fssh.py;h=476cb62ad9faa9b620a794a9cf7c6dec238e990d;hb=7829fea4a2c8936513fa95215b7d84997f814a69;hp=5359a6e5fb6303a430a0a6fc083ee0ab8089cbdb;hpb=d68951ac245150eeefa6e0f4156e4c1b5c9e9325;p=csit.git diff --git a/resources/libraries/python/ssh.py b/resources/libraries/python/ssh.py index 5359a6e5fb..476cb62ad9 100644 --- a/resources/libraries/python/ssh.py +++ b/resources/libraries/python/ssh.py @@ -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