Exemple #1
0
	def kill(self):
		"""
		Kill the job
		"""
		cmdlist = [self.cmds['scancel'], str(self.pid)]
		try:
			cmd.run(cmdlist)
		except (OSError, subprocess.CalledProcessError): # pragma: no cover
			pass
Exemple #2
0
	def submit(self):
		"""
		Submit the job
		@returns:
			The `utils.cmd.Cmd` instance
		"""
		# run self as a script
		c = cmd.run([sys.executable, path.realpath(__file__), self.script], bg = True)
		c.rc = 0
		return c
Exemple #3
0
	def submit (self):
		"""
		Try to submit the job
		"""
		c = cmd.run([
			sys.executable, 
			path.realpath(__file__), 
			self.script[-1] if isinstance(self.script, list) else self.script
		], bg = True)
		c.rc = 0
		return c
Exemple #4
0
	def alive(self):
		"""
		Tell if the job is alive
		@returns:
			`True` if it is else `False`
		"""
		if self.pid is None:
			return False
		cmdlist = [self.cmds['qstat'], '-j', str(self.pid)]
		try:
			r = cmd.run(cmdlist)
			return r.rc == 0
		except (OSError, subprocess.CalledProcessError):
			return False
Exemple #5
0
	def alive(self):
		"""
		Tell if the job is alive
		@returns:
			`True` if it is else `False`
		"""
		if self.pid is None:
			return False
		cmdlist = [self.cmds['squeue'], '-j', str(self.pid)]
		try:
			r = cmd.run(cmdlist)
			if r.rc != 0:
				return False
			return r.stdout.splitlines()[1].split()[0] == str(self.pid)
		except (OSError, subprocess.CalledProcessError):
			return False
Exemple #6
0
	def submit(self):
		"""
		Submit the job
		@returns:
			The `utils.cmd.Cmd` instance if succeed 
			else a `Box` object with stderr as the exception and rc as 1
		"""
		cmdlist = [self.cmds['sbatch'], self.script]
		try:
			r = cmd.run(cmdlist)
			# sbatch: Submitted batch job 99999999
			m = re.search(r'\s(\d+)$', r.stdout)
			if not m: # pragma: no cover
				r.rc = 1
			else:
				self.pid = m.group(1)

			return r
		except (OSError, subprocess.CalledProcessError) as ex: # pragma: no cover
			r = Box()
			r.stderr = str(ex)
			r.rc = 1
			return r
Exemple #7
0
	def submit(self):
		"""
		Submit the job
		@returns:
			The `utils.cmd.Cmd` instance if succeed 
			else a `Box` object with stderr as the exception and rc as 1
		"""
		cmdlist = [self.cmds['qsub'], self.script]
		try:
			r = cmd.run(cmdlist)
			# Your job 6556149 ("pSort.notag.3omQ6NdZ.0") has been submitted
			m = re.search(r'\s(\d+)\s', r.stdout)
			if not m:
				r.rc = 1
			else:
				self.pid = m.group(1)

			return r
		except (OSError, subprocess.CalledProcessError) as ex:
			r = Box()
			r.stderr = str(ex)
			r.rc = 1
			return r