annotate commons/core/launcher/Launcher.py @ 11:2da30502c2f1

Updated CompareOverlappingSmallQuery.xml
author m-zytnicki
date Thu, 14 Mar 2013 05:37:08 -0400
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 from commons.tools.CleanClusterNodesAfterRepet import CleanClusterNodesAfterRepet
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 from commons.core.stat.Stat import Stat
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 from commons.core.launcher.WriteScript import WriteScript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 from commons.core.sql.TableJobAdaptatorFactory import TableJobAdaptatorFactory
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 from commons.core.sql.Job import Job
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 import stat
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 import os
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 import re
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 import sys
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 import time
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 import glob
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 class Launcher(object):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 #TODO: remove unused parameters : query="", subject="", param="", job_table=""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 def __init__( self, jobdb, query="", subject="", param="", cdir="",
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 tmpdir="", job_table="", queue="", groupid="", acro="X",
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 chooseTemplateWithCopy = False, chooseTemplateLight = False):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 if jobdb.__class__.__name__ == "RepetJob":
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 self.jobdb = TableJobAdaptatorFactory.createInstance(jobdb, "jobs")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 self.jobdb = jobdb
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 self.jobdb.checkJobTable()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 if cdir == "":
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 cdir = os.getcwd()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 self.cdir = cdir
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 self.tmpdir = tmpdir
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 self.groupid = groupid
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 self.acronyme = acro
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 self._chooseTemplateWithCopy = chooseTemplateWithCopy
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 self._chooseTemplateLight = chooseTemplateLight
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 self.queue, self.lResources = self.getQueueNameAndResources(queue)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 self._createJobInstance()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 self._nbJobs = 0
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 def getQueueNameAndResources(self, configQueue):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 tokens = configQueue.replace("'","").split(" ")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 queueName = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 lResources = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 if tokens[0] != "":
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 if re.match(".*\.q", tokens[0]):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 queueName = tokens[0]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 lResources = tokens[1:]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 lResources = tokens
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 return queueName, lResources
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 def createGroupidIfItNotExist(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 if self.groupid == "":
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 self.job.groupid = str(os.getpid())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 self.job.groupid = self.groupid
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 def beginRun( self ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 self.createGroupidIfItNotExist()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 if self.jobdb.hasUnfinishedJob(self.job.groupid):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57 self.jobdb.waitJobGroup(self.job.groupid)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 self.jobdb.cleanJobGroup(self.job.groupid)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 ## Launch one job in parallel
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63 # @param cmdStart string command-line for the job to be launched
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64 # @param cmdFinish string command to retrieve result files
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 # @warning the jobname has to be defined outside from this method
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67 def runSingleJob(self, cmdStart, cmdFinish = "", cmdSize = "", cmdCopy = ""):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 if self._nbJobs == 0:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 self._nbJobs = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 pid = str(os.getpid())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 now = time.localtime()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72 #TODO: rename ClusterLauncher_ ...
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73 pyFileName = self.cdir + "/ClusterLauncher_" + self.job.groupid + "_" +\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 self.job.jobname + "_" + str(now[0]) + "-" + str(now[1]) +\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 "-" + str(now[2]) + "_" + pid + ".py"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 self.job.launcher = pyFileName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78 #TODO: to remove when refactoring is done
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 cmdStart = self._indentCmd(cmdStart)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 cmdFinish = self._indentCmd(cmdFinish)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 iWriteScript = WriteScript(self.job, self.jobdb, self.cdir, self.tmpdir, self._chooseTemplateWithCopy, self._chooseTemplateLight)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83 iWriteScript.run(cmdStart, cmdFinish, pyFileName, cmdSize, cmdCopy)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 os.chmod(pyFileName, stat.S_IRWXU+stat.S_IRGRP+stat.S_IXGRP+stat.S_IROTH+stat.S_IXOTH)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 sys.stdout.flush()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 log = self.jobdb.submitJob(self.job)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87 if log != 0:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88 print "ERROR while submitting job to the cluster"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 sys.exit(1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 def endRun(self, cleanNodes = False):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 string = "waiting for %i job(s) with groupid '%s' (%s)" % (self._nbJobs, self.job.groupid, time.strftime("%Y-%m-%d %H:%M:%S"))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93 print string; sys.stdout.flush()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 self.jobdb.waitJobGroup(self.job.groupid)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95 if self._nbJobs > 1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96 string = "all jobs with groupid '%s' are finished (%s)" % (self.job.groupid, time.strftime("%Y-%m-%d %H:%M:%S"))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97 print string; sys.stdout.flush()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 if cleanNodes:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100 string = "start cleaning cluster nodes (%s)" % time.strftime("%Y-%m-%d %H:%M:%S")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101 print string; sys.stdout.flush()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 self.cleanNodes()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103 string = "end cleaning cluster nodes (%s)" % time.strftime("%Y-%m-%d %H:%M:%S")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104 print string; sys.stdout.flush()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 statsExecutionTime = self.getStatsOfExecutionTime()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 if self._nbJobs > 1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108 print "execution time of all jobs (seconds): %f" % statsExecutionTime.getSum()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109 print "execution time per job: %s" % statsExecutionTime.string()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 sys.stdout.flush()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 self.jobdb.cleanJobGroup(self.job.groupid)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113 def getStatsOfExecutionTime(self, acronyme = ""):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114 stat = Stat()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 if acronyme == "":
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 pattern = "%s*.o*" % self.acronyme
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118 pattern = "%s*.o*" % acronyme
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119 lJobFiles = glob.glob(pattern)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120 for f in lJobFiles:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 fH = open(f, "r")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 while True:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 line = fH.readline()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124 if line == "":
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 break
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126 if "executionTime" in line:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 stat.add( float(line[:-1].split("=")[1] ) )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128 break
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129 fH.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 return stat
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132 def clean( self, acronyme = "", stdout = True, stderr = True ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133 lFileToRemove = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 if acronyme == "":
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135 acronyme = self.acronyme
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 pattern = "ClusterLauncher*%s*.py" % ( acronyme )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 lFileToRemove.extend(glob.glob( pattern ))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138 if stdout:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 pattern = "%s*.o*" % ( acronyme )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 lFileToRemove.extend(glob.glob( pattern ))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141 if stderr:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 pattern = "%s*.e*" % ( acronyme )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143 lFileToRemove.extend(glob.glob( pattern ))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 for file in lFileToRemove:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145 os.remove(file)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147 #TODO: handle of nodesMustBeCleaned => class attribute ?
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148 def runLauncherForMultipleJobs(self, acronymPrefix, lCmdsTuples, cleanMustBeDone = True, nodesMustBeCleaned = False):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 self.beginRun()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150 print "submitting job(s) with groupid '%s' (%s)" % (self.job.groupid, time.strftime("%Y-%m-%d %H:%M:%S"))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 for cmdsTuple in lCmdsTuples:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152 self._nbJobs += 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153 self.acronyme = "%s_%s" % (acronymPrefix, self._nbJobs)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 self.job.jobname = self.acronyme
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 if len(cmdsTuple) == 2:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156 self.runSingleJob(cmdsTuple[0], cmdsTuple[1])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 self.runSingleJob(cmdsTuple[0], cmdsTuple[1], cmdsTuple[2], cmdsTuple[3])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 self._createJobInstance()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160 self.createGroupidIfItNotExist()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 self.acronyme = acronymPrefix
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 self.endRun(nodesMustBeCleaned)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 if cleanMustBeDone:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 self.clean("%s_" % acronymPrefix)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 self.jobdb.close()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 def prepareCommands(self, lCmds, lCmdStart = [], lCmdFinish = [], lCmdSize = [], lCmdCopy = []):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168 cmdStart = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169 for cmd in lCmdStart:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 cmdStart += "%s\n\t" % cmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 for cmd in lCmds:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172 cmdStart += "%s\n\t" % cmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173 cmdFinish = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 for cmd in lCmdFinish:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 cmdFinish += "%s\n\t" % cmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176 cmdSize = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177 for cmd in lCmdSize:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178 cmdSize += "%s\n\t\t" % cmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 cmdCopy = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180 for cmd in lCmdCopy:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181 cmdCopy += "%s\n\t\t" % cmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 return (cmdStart, cmdFinish, cmdSize, cmdCopy)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184 #TODO: to remove when refactoring is done
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 def prepareCommands_withoutIndentation(self, lCmds, lCmdStart = [], lCmdFinish = [], lCmdSize = [], lCmdCopy = []):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186 cmdStart = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 for cmd in lCmdStart:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 cmdStart += "%s\n" % cmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189 for cmd in lCmds:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 cmdStart += "%s\n" % cmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 cmdFinish = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 for cmd in lCmdFinish:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193 cmdFinish += "%s\n" % cmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194 cmdSize = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195 for cmd in lCmdSize:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196 cmdSize += "%s\n\t\t" % cmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 cmdCopy = ""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 for cmd in lCmdCopy:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199 cmdCopy += "%s\n\t\t" % cmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 return (cmdStart, cmdFinish, cmdSize, cmdCopy)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 def getSystemCommand(self, prg, lArgs):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 systemCmd = "log = os.system(\"" + prg
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 for arg in lArgs:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 systemCmd += " " + arg
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206 systemCmd += "\")"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 return systemCmd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 def cleanNodes(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210 iCleanClusterNodeAfterRepet = CleanClusterNodesAfterRepet()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 iCleanClusterNodeAfterRepet.setLNodes(self.jobdb.getNodesListByGroupId(self.groupid))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212 iCleanClusterNodeAfterRepet.setTempDirectory(self.tmpdir)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 iCleanClusterNodeAfterRepet.setPattern("%s*" % self.groupid)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214 iCleanClusterNodeAfterRepet.run()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 #TODO: to remove when refactoring is done
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 def _indentCmd(self, cmd):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 lCmd = cmd.split("\n")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 cmd_Tab = "%s\n" % lCmd[0]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 for line in lCmd[1:-1]:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 cmd_Tab += "\t%s\n" % line
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 return cmd_Tab
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224 def _createJobInstance(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225 if self.lResources == []:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226 #To have mem_free=1G:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227 self.job = Job(queue=self.queue)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229 self.job = Job(queue=self.queue, lResources=self.lResources)