From d53eb38c31fb300d39c98fef81af99a40819246f Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 8 Dec 2008 13:35:55 +0100 Subject: allow using complex shell commandlines (including | etc.) for job tasks (handle with care, no tool exist precondition checking!) --- lib/python/Components/Task.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/python/Components/Task.py') diff --git a/lib/python/Components/Task.py b/lib/python/Components/Task.py index 9a768425..04e5c938 100644 --- a/lib/python/Components/Task.py +++ b/lib/python/Components/Task.py @@ -127,6 +127,7 @@ class Task(object): self.cmd = None self.cwd = "/tmp" self.args = [ ] + self.cmdline = None self.task_progress_changed = None self.output_line = "" job.addTask(self) @@ -141,6 +142,9 @@ class Task(object): self.global_preconditions.append(ToolExistsPrecondition()) self.postconditions.append(ReturncodePostcondition()) + def setCmdline(self, cmdline): + self.cmdline = cmdline + def checkPreconditions(self, immediate = False): not_met = [ ] if immediate: @@ -166,13 +170,15 @@ class Task(object): self.container.stdoutAvail.append(self.processStdout) self.container.stderrAvail.append(self.processStderr) - assert self.cmd is not None - assert len(self.args) >= 1 - if self.cwd is not None: self.container.setCWD(self.cwd) - print "execute:", self.container.execute(self.cmd, *self.args), self.cmd, self.args + if not self.cmd and self.cmdline: + print "execute:", self.container.execute(self.cmdline), self.cmdline + else: + assert self.cmd is not None + assert len(self.args) >= 1 + print "execute:", self.container.execute(self.cmd, *self.args), ' '.join(self.args) if self.initial_input: self.writeInput(self.initial_input) -- cgit v1.2.3 From 5b7a1c9dae868020473e9dcb79a5dfa442e019e1 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 6 Jan 2009 13:20:57 +0100 Subject: only kill actual containers on aborting tasks --- lib/python/Components/Task.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/python/Components/Task.py') diff --git a/lib/python/Components/Task.py b/lib/python/Components/Task.py index 04e5c938..df94f8a6 100644 --- a/lib/python/Components/Task.py +++ b/lib/python/Components/Task.py @@ -131,6 +131,7 @@ class Task(object): self.task_progress_changed = None self.output_line = "" job.addTask(self) + self.container = None def setCommandline(self, cmd, args): self.cmd = cmd @@ -211,7 +212,8 @@ class Task(object): self.finish() def abort(self): - self.container.kill() + if self.container: + self.container.kill() self.finish(aborted = True) def finish(self, aborted = False): -- cgit v1.2.3