use output file
[tests.git] / system / TestSsh.py
index 5b5ce94..6d721fa 100644 (file)
@@ -17,6 +17,7 @@
 
 import os.path
 import utils
+import shutil
 
 class TestSsh:
     
@@ -55,7 +56,7 @@ class TestSsh:
     def is_local(self):
         return TestSsh.is_local_hostname(self.hostname)
      
-    std_options="-o StrictHostKeyChecking=no -o BatchMode=yes "
+    std_options="-o BatchMode=yes -o StrictHostKeyChecking=no -o CheckHostIP=no -o ConnectTimeout=5 -o UserKnownHostsFile=/dev/null "
     
     def key_part (self):
         if not self.key:
@@ -100,6 +101,17 @@ class TestSsh:
             dirname=self.buildname
         return self.run("mkdir -p %s"%dirname)
 
+    def rmdir (self,dirname=None):
+        if self.is_local():
+            if dirname:
+                return shutil.rmtree(dirname)
+            return 0
+        if dirname:
+            dirname="%s/%s"%(self.buildname,dirname)
+        else:
+            dirname=self.buildname
+        return self.run("rm -rf %s"%dirname)
+
     def create_buildname_once (self):
         if self.is_local():
             return
@@ -153,7 +165,12 @@ class TestSsh:
             command += TestSsh.std_options
             if recursive: command += "-r "
             command += self.key_part()
-            command += "%s:%s/%s %s"%(self.hostname_part(),self.buildname,remote_file,local_file)
+            # absolute path - do not preprend buildname
+            if remote_file.find("/")==0:
+                remote_path=remote_file
+            else:
+                remote_path="%s/%s"%(self.buildname,remote_file)
+            command += "%s:%s %s"%(self.hostname_part(),remote_path,local_file)
         return utils.system(command)
 
     # this is only to avoid harmless message when host cannot be identified