X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2FTestSsh.py;h=7448ee7f7d00dfd21be117b949abba9423d5b159;hb=f395e8d3a322aae3b624a441e114931588f09126;hp=81b7fe8f15cc9ae230f92c00bc5cd91d38f6e0f1;hpb=c8d96644288f1efba9ee43ed4717497021650ef4;p=tests.git diff --git a/system/TestSsh.py b/system/TestSsh.py index 81b7fe8..7448ee7 100644 --- a/system/TestSsh.py +++ b/system/TestSsh.py @@ -29,9 +29,9 @@ class TestSsh: result='' for char in command: if char in "\\\"'<>&|;()$*~": - result +='\\'+char + result += '\\'+char else: - result +=char + result += char return result # check main IP address against the provided hostname @@ -77,7 +77,7 @@ class TestSsh: return "%s@%s"%(self.username,self.hostname) # command gets run on the right box - def actual_command (self, command, keep_stdin=False, dry_run=False): + def actual_command (self, command, keep_stdin=False, dry_run=False,backslash=True): if self.is_local(): return command ssh_command = "ssh " @@ -87,7 +87,11 @@ class TestSsh: ssh_command += TestSsh.std_options if self.unknown_host: ssh_command += TestSsh.unknown_option ssh_command += self.key_part() - ssh_command += "%s %s" %(self.hostname_part(),TestSsh.backslash_shell_specials(command)) + ssh_command += self.hostname_part() + " " + if backslash: + ssh_command += TestSsh.backslash_shell_specials(command) + else: + ssh_command += command return ssh_command # same in argv form @@ -170,7 +174,7 @@ class TestSsh: def copy (self,local_file,recursive=False,dry_run=False): if self.is_local(): return 0 - self.create_buildname_once() + self.create_buildname_once(dry_run) scp_command="scp " if not dry_run: scp_command += TestSsh.std_options @@ -180,7 +184,8 @@ class TestSsh: self.fullname(self.buildname),os.path.basename(local_file) or ".") if dry_run: utils.header ("DRY RUN TestSsh.copy %s"%scp_command) - return True + # need to be consistent with the non-dry-run mode + return 0 return utils.system(scp_command) def copy_abs (self,local_file,remote_file,recursive=False): @@ -198,14 +203,15 @@ class TestSsh: def copy_home (self, local_file, recursive=False): return self.copy_abs(local_file,os.path.basename(local_file),recursive) - def fetch (self, remote_file, local_file, recursive=False): + def fetch (self, remote_file, local_file, recursive=False, dry_run=False): if self.is_local(): command="cp " if recursive: command += "-r " command += "%s %s"%(remote_file,local_file) else: command="scp " - command += TestSsh.std_options + if not dry_run: + command += TestSsh.std_options if recursive: command += "-r " command += self.key_part() # absolute path - do not preprend buildname @@ -213,6 +219,7 @@ class TestSsh: remote_path=remote_file else: remote_path="%s/%s"%(self.buildname,remote_file) + remote_path=self.fullname(remote_path) command += "%s:%s %s"%(self.hostname_part(),remote_path,local_file) return utils.system(command)