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

utils/ssh: Fix SSHTransferHandle when using SCP

Using SSHConnection(use_scp=True) lead to an exception:

    UnboundLocalError: local variable 'handle' referenced before assignment

This is cause by some (false) cyclic dependency between initialization
of SSHTransferHandle and creation of the SCPClient. We can fix that by
adding a level of indirection to tie together both objects.
This commit is contained in:
Douglas Raillard 2023-09-11 14:01:55 +01:00 committed by Marc Bonnici
parent 9b15807c17
commit 1c0223556f

View File

@ -525,7 +525,9 @@ class SshConnection(SshConnectionBase):
# No timeout
elif self.use_scp:
scp = self._get_scp(timeout, callback=handle.progress_cb)
def progress_cb(*args, **kwargs):
return handle.progress_cb(*args, **kwargs)
scp = self._get_scp(timeout, callback=progress_cb)
handle, cm = make_handle(scp)
scp_cmd = getattr(scp, 'put' if action == 'push' else 'get')