allow using complex shell commandlines (including | etc.) for job tasks (handle with...
authorFraxinas <andreas.frisch@multimedia-labs.de>
Mon, 8 Dec 2008 12:35:55 +0000 (13:35 +0100)
committerFraxinas <andreas.frisch@multimedia-labs.de>
Mon, 8 Dec 2008 12:35:55 +0000 (13:35 +0100)
lib/python/Components/Task.py

index 9a7684250008c295087f17516793d911fddd0cfb..04e5c9385948e0e4426619787ada2fa3199b8bb4 100644 (file)
@@ -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)