don't offer to retry non-recoverable tasks & error catching for MplexTask
authorAndreas Frisch <andreas.frisch@multimedia-labs.de>
Mon, 15 Sep 2008 14:18:10 +0000 (14:18 +0000)
committerAndreas Frisch <andreas.frisch@multimedia-labs.de>
Mon, 15 Sep 2008 14:18:10 +0000 (14:18 +0000)
lib/python/Components/Task.py
lib/python/Plugins/Extensions/DVDBurn/Process.py

index d5fffbc66b4da2f07358e1eca212d55084f8536c..3e648df179c21a5b3b8837eb4346c7ad46a0f2f7 100644 (file)
@@ -261,7 +261,11 @@ class JobManager:
                if problems:
                        from Tools import Notifications
                        from Screens.MessageBox import MessageBox
                if problems:
                        from Tools import Notifications
                        from Screens.MessageBox import MessageBox
-                       Notifications.AddNotificationWithCallback(self.errorCB, MessageBox, _("Error: %s\nRetry?") % (problems[0].getErrorMessage(task)))
+                       if problems[0].RECOVERABLE:
+                               Notifications.AddNotificationWithCallback(self.errorCB, MessageBox, _("Error: %s\nRetry?") % (problems[0].getErrorMessage(task)))
+                       else:
+                               Notifications.AddNotification(MessageBox, _("Error") + (': %s') % (problems[0].getErrorMessage(task)), type = MessageBox.TYPE_ERROR )
+                               self.errorCB(False)
                        return
                        #self.failed_jobs.append(self.active_job)
 
                        return
                        #self.failed_jobs.append(self.active_job)
 
@@ -317,7 +321,7 @@ class Condition:
        RECOVERABLE = False
 
        def getErrorMessage(self, task):
        RECOVERABLE = False
 
        def getErrorMessage(self, task):
-               return _("An error has occured. (%s)") % (self.__class__.__name__)
+               return _("An error has occured. (%s in %s)") % (self.__class__.__name__, task.__class__.__name__)
 
 class WorkspaceExistsPrecondition(Condition):
        def check(self, task):
 
 class WorkspaceExistsPrecondition(Condition):
        def check(self, task):
index 67654f619e3f0e054d85db664c185612f3af390d..ec674ef21ec1639886f7bd3203bfe792038f9c65 100644 (file)
@@ -32,7 +32,7 @@ class mpeg2encTask(Task):
                self.container.readFromFile(self.inputFile)
 
        def processOutputLine(self, line):
                self.container.readFromFile(self.inputFile)
 
        def processOutputLine(self, line):
-               print "[mpeg2encTask]", line
+               print "[mpeg2encTask]", line[:-1]
 
 class spumuxTask(Task):
        def __init__(self, job, xmlfile, inputfile, outputfile):
 
 class spumuxTask(Task):
        def __init__(self, job, xmlfile, inputfile, outputfile):
@@ -49,7 +49,7 @@ class spumuxTask(Task):
                self.container.readFromFile(self.inputFile)
 
        def processStderr(self, data):
                self.container.readFromFile(self.inputFile)
 
        def processStderr(self, data):
-               print "[spumuxTask]", data
+               print "[spumuxTask]", data[:-1]
 
        def processStdout(self, data):
                pass
 
        def processStdout(self, data):
                pass
@@ -107,7 +107,7 @@ class DemuxTask(Task):
                self.generated_files.append(file)
 
        def haveProgress(self, progress):
                self.generated_files.append(file)
 
        def haveProgress(self, progress):
-               print "PROGRESS [%s]" % progress
+               #print "PROGRESS [%s]" % progress
                MSG_CHECK = "check & synchronize audio file"
                MSG_DONE = "done..."
                if progress == "preparing collection(s)...":
                MSG_CHECK = "check & synchronize audio file"
                MSG_DONE = "done..."
                if progress == "preparing collection(s)...":
@@ -144,22 +144,42 @@ class DemuxTask(Task):
                        for f in self.generated_files:
                                os.remove(f)
 
                        for f in self.generated_files:
                                os.remove(f)
 
+class MplexTaskPostcondition(Condition):
+       def check(self, task):
+               return task.error is None
+
+       def getErrorMessage(self, task):
+               print "[MplexTaskPostcondition] getErrorMessage", task
+               return {
+                       task.ERROR_UNDERRUN: ("Can't multiplex source video!"),
+                       task.ERROR_UNKNOWN: ("An unknown error occured!")
+               }[task.error]
+
 class MplexTask(Task):
 class MplexTask(Task):
+       ERROR_UNDERRUN, ERROR_UNKNOWN = range(2)
        def __init__(self, job, outputfile, inputfiles=None, demux_task=None):
                Task.__init__(self, job, "Mux ES into PS")
                self.weighting = 500
                self.demux_task = demux_task
        def __init__(self, job, outputfile, inputfiles=None, demux_task=None):
                Task.__init__(self, job, "Mux ES into PS")
                self.weighting = 500
                self.demux_task = demux_task
+               self.postconditions.append(MplexTaskPostcondition())
                self.setTool("/usr/bin/mplex")
                self.args += ["-f8", "-o", outputfile, "-v1"]
                if inputfiles:
                        self.args += inputfiles
 
        def prepare(self):
                self.setTool("/usr/bin/mplex")
                self.args += ["-f8", "-o", outputfile, "-v1"]
                if inputfiles:
                        self.args += inputfiles
 
        def prepare(self):
+               self.error = None                       
                if self.demux_task:
                        self.args += self.demux_task.generated_files
 
        def processOutputLine(self, line):
                if self.demux_task:
                        self.args += self.demux_task.generated_files
 
        def processOutputLine(self, line):
-               print "[MplexTask] processOutputLine=", line
+               print "[MplexTask] processOutputLine=", line[:-1]
+               if line.startswith("**ERROR:"):
+                       if line.find("Frame data under-runs detected") != -1:
+                               self.error = self.ERROR_UNDERRUN
+                               print "BUFFER UNDERRUN ERROR !!!"
+                       else:
+                               self.error = self.ERROR_UNKNOWN
 
 class RemoveESFiles(Task):
        def __init__(self, job, demux_task):
 
 class RemoveESFiles(Task):
        def __init__(self, job, demux_task):
@@ -184,7 +204,7 @@ class DVDAuthorTask(Task):
                self.menupreview = job.menupreview
 
        def processOutputLine(self, line):
                self.menupreview = job.menupreview
 
        def processOutputLine(self, line):
-               print "[DVDAuthorTask] processOutputLine=", line
+               print "[DVDAuthorTask] processOutputLine=", line[:-1]
                if not self.menupreview and line.startswith("STAT: Processing"):
                        self.callback(self, [], stay_resident=True)
 
                if not self.menupreview and line.startswith("STAT: Processing"):
                        self.callback(self, [], stay_resident=True)
 
@@ -204,6 +224,7 @@ class WaitForResidentTasks(Task):
                        callback(self, [])
 
 class BurnTaskPostcondition(Condition):
                        callback(self, [])
 
 class BurnTaskPostcondition(Condition):
+       RECOVERABLE = True
        def check(self, task):
                return task.error is None
 
        def check(self, task):
                return task.error is None