fix progress scaling and remove unneeded project paramter from dvd media toolbox
[enigma2.git] / lib / python / Plugins / Extensions / DVDBurn / Process.py
index 74f23f1512fdb24cc5f78f9c23a4e8acbb2a5c7b..3bf9111012fac4d92b5529d2aaaac92791b57e23 100644 (file)
@@ -1,4 +1,5 @@
-from Components.Task import Task, Job, job_manager, DiskspacePrecondition, Condition, ToolExistsPrecondition
+from Components.Task import Task, Job, DiskspacePrecondition, Condition, ToolExistsPrecondition
+from Components.Harddisk import harddiskmanager
 from Screens.MessageBox import MessageBox
 
 class png2yuvTask(Task):
@@ -7,7 +8,7 @@ class png2yuvTask(Task):
                self.setTool("/usr/bin/png2yuv")
                self.args += ["-n1", "-Ip", "-f25", "-j", inputfile]
                self.dumpFile = outputfile
-               self.weighting = 10
+               self.weighting = 15
 
        def run(self, callback, task_progress_changed):
                Task.run(self, callback, task_progress_changed)
@@ -23,7 +24,7 @@ class mpeg2encTask(Task):
                self.setTool("/usr/bin/mpeg2enc")
                self.args += ["-f8", "-np", "-a2", "-o", outputfile]
                self.inputFile = inputfile
-               self.weighting = 10
+               self.weighting = 25
                
        def run(self, callback, task_progress_changed):
                Task.run(self, callback, task_progress_changed)
@@ -39,7 +40,7 @@ class spumuxTask(Task):
                self.args += [xmlfile]
                self.inputFile = inputfile
                self.dumpFile = outputfile
-               self.weighting = 10
+               self.weighting = 15
 
        def run(self, callback, task_progress_changed):
                Task.run(self, callback, task_progress_changed)
@@ -76,7 +77,7 @@ class CopyMeta(Task):
                        if file.startswith(filename+"."):
                                self.args += [path+'/'+file]
                self.args += [self.job.workspace]
-               self.weighting = 10
+               self.weighting = 15
 
 class DemuxTask(Task):
        def __init__(self, job, inputfile):
@@ -167,9 +168,9 @@ class MplexTaskPostcondition(Condition):
 
 class MplexTask(Task):
        ERROR_UNDERRUN, ERROR_UNKNOWN = range(2)
-       def __init__(self, job, outputfile, inputfiles=None, demux_task=None):
+       def __init__(self, job, outputfile, inputfiles=None, demux_task=None, weighting = 500):
                Task.__init__(self, job, "Mux ES into PS")
-               self.weighting = 500
+               self.weighting = weighting
                self.demux_task = demux_task
                self.postconditions.append(MplexTaskPostcondition())
                self.setTool("/usr/bin/mplex")
@@ -201,6 +202,7 @@ class RemoveESFiles(Task):
                Task.__init__(self, job, "Remove temp. files")
                self.demux_task = demux_task
                self.setTool("/bin/rm")
+               self.weighting = 10
 
        def prepare(self):
                self.args += ["-f"]
@@ -210,7 +212,6 @@ class RemoveESFiles(Task):
 class DVDAuthorTask(Task):
        def __init__(self, job, diskspaceNeeded):
                Task.__init__(self, job, "Authoring DVD")
-
                self.global_preconditions.append(DiskspacePrecondition(diskspaceNeeded))
                self.weighting = 300
                self.setTool("/usr/bin/dvdauthor")
@@ -264,7 +265,7 @@ class BurnTask(Task):
                self.postconditions.append(BurnTaskPostcondition())
                self.setTool("/bin/growisofs")
                volName = self.getASCIIname(job.project.settings.name.getValue())
-               self.args += [ "-dvd-compat", "-Z", "/dev/cdroms/cdrom0", "-V", volName, "-publisher", "Dreambox", "-use-the-force-luke=dummy" ]
+               self.args += [ "-dvd-compat", "-Z", "/dev/" + harddiskmanager.getCD(), "-V", volName, "-publisher", "Dreambox", "-use-the-force-luke=dummy" ]
                self.args += extra_args
 
        def getASCIIname(self, name):
@@ -302,7 +303,7 @@ class BurnTask(Task):
                                self.error = self.ERROR_SIZE
                        elif line.find("write failed") != -1:
                                self.error = self.ERROR_WRITE_FAILED
-                       elif line.find("unable to open64(\"/dev/cdroms/cdrom0\",O_RDONLY): No such file or directory") != -1: # fixme
+                       elif line.find("unable to open64(") != -1 and line.find(",O_RDONLY): No such file or directory") != -1:
                                self.error = self.ERROR_DVDROM
                        elif line.find("media is not recognized as recordable DVD") != -1:
                                self.error = self.ERROR_NOTWRITEABLE
@@ -321,12 +322,14 @@ class RemoveDVDFolder(Task):
                Task.__init__(self, job, "Remove temp. files")
                self.setTool("/bin/rm")
                self.args += ["-rf", self.job.workspace]
+               self.weighting = 10
 
 class PreviewTask(Task):
        def __init__(self, job):
                Task.__init__(self, job, "Preview")
                self.postconditions.append(PreviewTaskPostcondition())
                self.job = job
+               self.weighting = 10
 
        def run(self, callback, task_progress_changed):
                self.callback = callback
@@ -335,6 +338,9 @@ class PreviewTask(Task):
                        self.previewProject()
                else:
                        self.job.project.session.openWithCallback(self.previewCB, MessageBox, _("Do you want to preview this DVD before burning?"), timeout = 60, default = False)
+
+       def abort(self):
+               self.finish(aborted = True)
        
        def previewCB(self, answer):
                if answer == True:
@@ -429,7 +435,7 @@ class MenuImageTask(Task):
        def __init__(self, job, menu_count, spuxmlfilename, menubgpngfilename, highlightpngfilename):
                Task.__init__(self, job, "Create Menu %d Image" % menu_count)
                self.postconditions.append(ImagingPostcondition())
-               self.weighting = 20 
+               self.weighting = 10
                self.job = job
                self.Menus = job.Menus
                self.menu_count = menu_count
@@ -559,7 +565,7 @@ class Menus:
                        mpeg2encTask(job, job.workspace+"/dvdmenubg"+num+".yuv", menubgm2vfilename)
                        menubgmpgfilename = job.workspace+"/dvdmenubg"+num+".mpg"
                        menuaudiofilename = s.menuaudio.getValue()
-                       MplexTask(job, outputfile=menubgmpgfilename, inputfiles = [menubgm2vfilename, menuaudiofilename])
+                       MplexTask(job, outputfile=menubgmpgfilename, inputfiles = [menubgm2vfilename, menuaudiofilename], weighting = 20)
                        menuoutputfilename = job.workspace+"/dvdmenu"+num+".mpg"
                        spumuxTask(job, spuxmlfilename, menubgmpgfilename, menuoutputfilename)
                
@@ -662,7 +668,7 @@ class DVDJob(Job):
                DVDAuthorTask(self, diskSpaceNeeded)
                
                nr_titles = len(self.project.titles)
-               
+
                if self.menupreview:
                        PreviewTask(self)
                else:
@@ -705,18 +711,3 @@ class DVDdataJob(Job):
                        CopyMeta(self, title.inputfile)
                BurnTask(self, ["-follow-links", self.workspace])
                RemoveDVDFolder(self)
-
-def Burn(session, project):
-       j = DVDJob(project)
-       job_manager.AddJob(j)
-       return j
-
-def PreviewMenu(session, project):
-       j = DVDJob(project, menupreview=True)
-       job_manager.AddJob(j)
-       return j
-
-def BurnDataTS(session, project):
-       j = DVDdataJob(project)
-       job_manager.AddJob(j)
-       return j