Lines Matching refs:self
32 def __init__(self, cmd, input = None, output = None, bufsize = -1):
33 self.status = -1
37 self.tochild = os.fdopen(p2c_write, 'w', bufsize)
52 self.fromchild = os.fdopen(c2p_read, 'r', bufsize)
65 self.pid = os.fork()
66 if self.pid == 0:
78 def poll(self):
79 if self.status < 0:
80 pid, status = os.waitpid(self.pid, os.WNOHANG)
81 if pid == self.pid:
82 self.status = status
83 return self.status
85 def wait(self):
86 if self.status < 0:
87 pid, status = os.waitpid(self.pid, 0)
88 if pid == self.pid:
89 self.status = status
90 return self.status
94 def __init__(self):
95 self.walltime = None
96 self.queue = None
97 self.properties = None
100 self.name = None
101 self.afterok = None
102 self.notify = None
103 self.stderr = None
104 self.stdout = None
107 self.oarhost = None
108 self.oarsub = 'oarsub'
110 self.jobid = re.compile('IdJob = (\S+)')
111 #self.outfile = open("jobnames.dat", "a+")
113 def build(self, script, args = []):
114 self.cmd = [ self.oarsub ]
118 if self.properties:
119 self.cmd.append('-p"%s"' % self.properties )
121 if self.queue:
122 self.cmd.append('-q "%s"' % self.queue)
124 if self.walltime:
125 self.cmd.append('-l walltime=%s' % self.walltime)
128 self.script = os.getcwd()
130 self.script = script
132 self.cmd.extend(args)
133 self.cmd.append(self.script)
134 #cmd = [ 'ssh', '-x', self.oarhost, '"cd %s; %s"' % (os.getcwd(), self.command) ]
135 self.command = ' '.join(self.cmd)
137 print "command: [%s]" % self.command
139 def do(self):
140 oar = MyPOpen(self.cmd)
141 self.result = oar.fromchild.read()
144 if ec != 0 and self.oarhost:
145 pstdin, pstdout = os.popen4(self.command)
146 self.result = pstdout.read()
148 jobid = self.jobid.match(self.result)
150 print "Couldn't get jobid from [%s]" % self.result
153 #self.outfile.write("%d %s\n" %(int(jobid.group(1)), self.name));
154 #self.outfile.flush()
155 self.result = jobid.group(1)
160 def __init__(self):
161 self.afterok = None
162 self.hold = False
163 self.join = False
164 self.keep_stdout = False
165 self.keep_stderr = False
166 self.node_type = None
167 self.mail_abort = False
168 self.mail_begin = False
169 self.mail_end = False
170 self.name = None
171 self.stdout = None
172 self.priority = None
173 self.queue = None
174 self.pbshost = None
175 self.qsub = 'qsub'
176 self.env = {}
178 def build(self, script, args = []):
179 self.cmd = [ self.qsub ]
181 if self.env:
183 arg += ','.join([ '%s=%s' % i for i in self.env.iteritems() ])
184 self.cmd.append(arg)
186 if self.hold:
187 self.cmd.append('-h')
189 if self.stdout:
190 self.cmd.append('-olocalhost:' + self.stdout)
192 if self.keep_stdout and self.keep_stderr:
193 self.cmd.append('-koe')
194 elif self.keep_stdout:
195 self.cmd.append('-ko')
196 elif self.keep_stderr:
197 self.cmd.append('-ke')
199 self.cmd.append('-kn')
201 if self.join:
202 self.cmd.append('-joe')
204 if self.node_type:
205 self.cmd.append('-lnodes=' + self.node_type)
207 if self.mail_abort or self.mail_begin or self.mail_end:
209 if self.mail_abort:
211 if self.mail_begin:
213 if self.mail_end:
216 self.cmd.append('-m ' + flags)
218 self.cmd.append('-mn')
220 if self.name:
221 self.cmd.append("-N%s" % self.name)
223 if self.priority:
224 self.cmd.append('-p' + self.priority)
226 if self.queue:
227 self.cmd.append('-q' + self.queue)
229 if self.afterok:
230 self.cmd.append('-Wdepend=afterok:%s' % self.afterok)
232 self.cmd.extend(args)
233 self.script = script
234 self.command = ' '.join(self.cmd + [ self.script ])
236 def do(self):
237 pbs = MyPOpen(self.cmd + [ self.script ])
238 self.result = pbs.fromchild.read()
241 if ec != 0 and self.pbshost:
242 cmd = ' '.join(self.cmd + [ '-' ])
243 cmd = [ 'ssh', '-x', self.pbshost, cmd ]
244 self.command = ' '.join(cmd)
245 ssh = MyPOpen(cmd, input = self.script)
246 self.result = ssh.fromchild.read()