From 4194b1dd5e0ccf1186a2d01650f01b341d13cca5 Mon Sep 17 00:00:00 2001 From: Jonathan Paynter Date: Thu, 10 Sep 2020 13:52:18 +0100 Subject: [PATCH] utils/ssh: Add remote path formatter method --- devlib/utils/ssh.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/devlib/utils/ssh.py b/devlib/utils/ssh.py index b8cbc55..9d1e75d 100644 --- a/devlib/utils/ssh.py +++ b/devlib/utils/ssh.py @@ -302,9 +302,12 @@ class SshConnectionBase(ConnectionBase): self.options = {} logger.debug('Logging in {}@{}'.format(username, host)) + def fmt_remote_path(self, path): + return '{}@{}:{}'.format(self.username, self.host, path) + def push(self, sources, dest, timeout=30): # Quote the destination as SCP would apply globbing too - dest = '{}@{}:{}'.format(self.username, self.host, quote(dest)) + dest = self.fmt_remote_path(quote(dest)) paths = sources + [dest] return self._scp(paths, timeout) @@ -312,7 +315,7 @@ class SshConnectionBase(ConnectionBase): # First level of escaping for the remote shell sources = ' '.join(map(quote, sources)) # All the sources are merged into one scp parameter - sources = '{}@{}:{}'.format(self.username, self.host, sources) + sources = self.fmt_remote_path(sources) paths = [sources, dest] self._scp(paths, timeout)