add eBatch function for running system commands sequentially
authorAndreas Frisch <andreas.frisch@multimedia-labs.de>
Wed, 29 Oct 2008 09:09:25 +0000 (09:09 +0000)
committerAndreas Frisch <andreas.frisch@multimedia-labs.de>
Wed, 29 Oct 2008 09:09:25 +0000 (09:09 +0000)
lib/python/Components/Console.py

index c451eba79914e1acc43d94deec25e2166862e40f..b03482409934a1670c9d5ddaaa4a9baae3677fc5 100644 (file)
@@ -25,6 +25,21 @@ class Console(object):
                if retval:
                        self.finishedCB(name, retval)
 
                if retval:
                        self.finishedCB(name, retval)
 
+       def eBatch(self, cmds, callback, debug=False):
+               self.debug = debug
+               cmd = cmds.pop(0)
+               self.ePopen(cmd, self.eBatchCB, [cmds, callback, cmd])
+
+       def eBatchCB(self, data, retval, extra_args):
+               (cmds, callback, lastcmd) = extra_args
+               if self.debug:
+                       print '[eBatch] cmd="%s", retval=%s, cmds left=%d, data:\n%s' % (lastcmd, retval, len(cmds), data)
+               if len(cmds):
+                       cmd = cmds.pop(0)
+                       self.ePopen(cmd, self.eBatchCB, [cmds, callback, cmd])
+               else:
+                       callback()
+
        def dataAvailCB(self, name, data):
                self.appResults[name] += data
 
        def dataAvailCB(self, name, data):
                self.appResults[name] += data