mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-11-04 07:51:21 +00:00 
			
		
		
		
	utils/ssh: Add remote path formatter method
This commit is contained in:
		
				
					committed by
					
						
						Marc Bonnici
					
				
			
			
				
	
			
			
			
						parent
						
							ef2d1a6fa4
						
					
				
				
					commit
					4194b1dd5e
				
			@@ -302,9 +302,12 @@ class SshConnectionBase(ConnectionBase):
 | 
				
			|||||||
        self.options = {}
 | 
					        self.options = {}
 | 
				
			||||||
        logger.debug('Logging in {}@{}'.format(username, host))
 | 
					        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):
 | 
					    def push(self, sources, dest, timeout=30):
 | 
				
			||||||
        # Quote the destination as SCP would apply globbing too
 | 
					        # 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]
 | 
					        paths = sources + [dest]
 | 
				
			||||||
        return self._scp(paths, timeout)
 | 
					        return self._scp(paths, timeout)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -312,7 +315,7 @@ class SshConnectionBase(ConnectionBase):
 | 
				
			|||||||
        # First level of escaping for the remote shell
 | 
					        # First level of escaping for the remote shell
 | 
				
			||||||
        sources = ' '.join(map(quote, sources))
 | 
					        sources = ' '.join(map(quote, sources))
 | 
				
			||||||
        # All the sources are merged into one scp parameter
 | 
					        # 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]
 | 
					        paths = [sources, dest]
 | 
				
			||||||
        self._scp(paths, timeout)
 | 
					        self._scp(paths, timeout)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user