23 return os.path.abspath(os.path.expanduser(x))
25 def remote_mkdirs(host, folder, debug):
29 command =
"ssh %s '%s -c \"import os, sys; print %s, os.path.exists(os.path.abspath(os.path.expanduser(sys.argv[1]))) \" %s'"
31 tag =
'%s' % id(command)
32 out = os.popen(command % (host.name, host.python, tag, folder))
33 lines = out.readlines()
38 if line.split()[0] == tag:
39 exists = eval(line.split()[-1])
45 print 'Creating temporary directory %s on the host %s... ' % (folder, host.name)
47 command =
"ssh %s '%s -c \"import os, sys; os.makedirs(sys.argv[1])\" %s\' > /dev/null"
48 os.system(command % (host.name, host.python, folder))
54 s =
'%s(name=%s, nice=%d, python=%s)'
56 return s % (self.__class__.__name__, self.name, self.niceness, self.python)
60 def __init__(self, name, temp_path, n_cpu=1, niceness=0, python='python', init_cmd=''):
63 self.set_temp_path(temp_path)
64 self.set_niceness(niceness)
66 self.isd_shared_lib_path =
None
68 self.use_n_cpu = self.n_cpu
69 self.init_cmd = init_cmd
71 def set_temp_path(self, temp_path):
73 self.temp_path = abspath(temp_path)
75 def set_niceness(self, n):
79 def create_host_list(host_names, temp_path, niceness=0, python='python', init_cmd=''):
81 host_list = [Host(name, temp_path, niceness=niceness, python=python, init_cmd=init_cmd)
for name
in host_names]