From f7b7aaf5276ebfc467228da352f576f0358704bd Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Tue, 26 May 2020 18:14:23 +0100 Subject: [PATCH] utils/ssh: Do not attempt to push files recursivley and add logging No longer recursively attempt to push a file to the target. If the second attempt goes wrong we assume there is something else wrong and therefore let the error propagate. Also log the original error in case it is not the error we were expecting. --- devlib/utils/ssh.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devlib/utils/ssh.py b/devlib/utils/ssh.py index bc5c21b..57c366b 100644 --- a/devlib/utils/ssh.py +++ b/devlib/utils/ssh.py @@ -444,7 +444,8 @@ class SshConnection(SshConnectionBase): try: sftp.put(src, dst) # Maybe the dst was a folder - except OSError: + except OSError as e: + logger.debug('sftp transfer error: {}'.format(repr(e))) # This might fail if the folder already exists with contextlib.suppress(IOError): sftp.mkdir(dst) @@ -453,8 +454,8 @@ class SshConnection(SshConnectionBase): dst, os.path.basename(src), ) - - return cls._push_file(sftp, src, new_dst) + logger.debug('Trying: {} -> {}'.format(src, new_dst)) + sftp.put(src, new_dst) @classmethod