1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

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.
This commit is contained in:
Marc Bonnici 2020-05-26 18:14:23 +01:00 committed by setrofim
parent 569e4bd057
commit f7b7aaf527

View File

@ -444,7 +444,8 @@ class SshConnection(SshConnectionBase):
try: try:
sftp.put(src, dst) sftp.put(src, dst)
# Maybe the dst was a folder # 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 # This might fail if the folder already exists
with contextlib.suppress(IOError): with contextlib.suppress(IOError):
sftp.mkdir(dst) sftp.mkdir(dst)
@ -453,8 +454,8 @@ class SshConnection(SshConnectionBase):
dst, dst,
os.path.basename(src), os.path.basename(src),
) )
logger.debug('Trying: {} -> {}'.format(src, new_dst))
return cls._push_file(sftp, src, new_dst) sftp.put(src, new_dst)
@classmethod @classmethod