1 #this class is used for any ssh command and
2 #also for any remote or a local command independently
3 #on which box this must be done.
4 #new TestSsh object take like an argument an instance
5 #of the class where it was created
12 def __init__(self,caller):
17 return self.caller.hostname()
19 return self.caller.is_local()
21 return self.caller.buildname()
23 # command gets run on the right box
24 def to_host(self,command):
25 if self.caller.is_local():
28 return "ssh %s %s"%(self.hostname(),utils.backslash_shell_specials(command))
30 def full_command(self,command):
31 return self.to_host(self.caller.host_to_guest(command))
33 def run_in_guest (self,command):
34 return utils.system(self.full_command(command))
36 def run_in_host (self,command):
37 return utils.system(self.to_host(command))
40 def run_in_guest_piped (self,local,remote):
41 return utils.system(local+" | "+self.full_command(remote))
43 def run_in_buildname (self,command):
45 return utils.system(command)
48 ssh_comand += "-i %s.rsa "%(self.caller.key)
49 ssh_command += "%s/%s"%(self.buildname,utils.backslash_shell_specials(command))
50 return utils.system(ssh_command)
52 def copy (self,local_file,recursive=False):
56 if recursive: command += "-r "
58 command += "-i %s.rsa "
59 command +="%s %s:%s/%s"%(local_file,self.hostname(),self.buildname,
60 os.path.basename(local_file) or ".")
61 return utils.system(command)