+ # ab. paths remain as-is
+ if not abs:
+ if dirname:
+ dirname="%s/%s"%(self.buildname,dirname)
+ else:
+ dirname=self.buildname
+ dirname=self.fullname(dirname)
+ if dirname=='.': return
+ return self.run("mkdir -p %s"%dirname,dry_run=dry_run)
+
+ def rmdir (self,dirname=None, dry_run=False):
+ if self.is_local():
+ if dirname:
+ return shutil.rmtree(dirname)
+ return 0
+ if dirname:
+ dirname="%s/%s"%(self.buildname,dirname)
+ else:
+ dirname=self.buildname
+ dirname=self.fullname(dirname)
+ return self.run("rm -rf %s"%dirname, dry_run=dry_run)
+
+ def create_buildname_once (self, dry_run):
+ if self.is_local():
+ return
+ # create remote buildname on demand
+ try:
+ self.buildname_created
+ except:
+ self.mkdir(dry_run=dry_run)
+ self.buildname_created=True
+
+ def copy (self,local_file,recursive=False,dry_run=False):
+ if self.is_local():
+ return 0
+ self.create_buildname_once(dry_run)
+ scp_command="scp "
+ if not dry_run:
+ scp_command += TestSsh.std_options
+ if recursive: scp_command += "-r "
+ scp_command += self.key_part()
+ scp_command += "%s %s:%s/%s"%(local_file,self.hostname_part(),
+ self.fullname(self.buildname),os.path.basename(local_file) or ".")
+ if dry_run:
+ utils.header ("DRY RUN TestSsh.copy %s"%scp_command)
+ # 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):
+ if self.is_local():
+ dest=""
+ else:
+ dest= "%s:"%self.hostname_part()
+ scp_command="scp "
+ scp_command += TestSsh.std_options
+ if recursive: scp_command += "-r "
+ scp_command += self.key_part()
+ scp_command += "%s %s%s"%(local_file,dest,remote_file)
+ return utils.system(scp_command)
+
+ 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, dry_run=False):
+ if self.is_local():
+ command="cp "
+ if recursive: command += "-r "
+ command += "%s %s"%(remote_file,local_file)
+ else:
+ command="scp "
+ if not dry_run:
+ command += TestSsh.std_options
+ if recursive: command += "-r "
+ command += self.key_part()
+ # absolute path - do not preprend buildname
+ if remote_file.find("/")==0:
+ 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)