fix progress scaling and remove unneeded project paramter from dvd media toolbox
[enigma2.git] / lib / python / Plugins / Extensions / DVDBurn / DVDToolbox.py
index 02ed75adb86c01b45bea7e851742a903342e4182..058c30ca57b97c49b0aca7c9302d33c5886d45bc 100644 (file)
@@ -7,6 +7,7 @@ from Components.Sources.StaticText import StaticText
 from Components.Sources.Progress import Progress
 from Components.Task import Task, Job, job_manager, Condition
 from Components.ScrollLabel import ScrollLabel
+from Components.Harddisk import harddiskmanager
 
 class DVDToolbox(Screen):
        skin = """
@@ -25,9 +26,8 @@ class DVDToolbox(Screen):
                    <widget source="space_label" render="Label" position="20,414" size="520,22" zPosition="2" font="Regular;18" halign="center" transparent="1" foregroundColor="#000000" />
                </screen>"""
 
-       def __init__(self, session, project = None):
+       def __init__(self, session):
                Screen.__init__(self, session)
-               self.project = project
                
                self["key_red"] = StaticText(_("Exit"))
                self["key_green"] = StaticText(_("Update"))
@@ -68,7 +68,7 @@ class DVDToolbox(Screen):
                job = DVDinfoJob(self)
                job_manager.AddJob(job)
                
-       def infoJobCB(self):
+       def infoJobCB(self, in_background=False):
                capacity = 1
                used = 0
                infotext = ""
@@ -94,13 +94,22 @@ class DVDToolbox(Screen):
                                        print "[Disc status] capacity=%d, used=0" % (capacity)
                                        capacity = used
                                        used = 0
+                       elif line.find("Free Blocks:") > -1:
+                               try:
+                                       size = eval(line[14:].replace("KB","*1024"))
+                               except:
+                                       size = 0
+                               if size > 0:
+                                       capacity = size
+                                       used = capacity-used                            
+                                       print "[free blocks] capacity=%d, used=%d" % (capacity, used)
                        infotext += line
                self["details"].setText(infotext)
                if self.formattable:
                        self["key_yellow"].text = _("Format")
                else:
                        self["key_yellow"].text = ""
-               percent = 100 * used / capacity
+               percent = 100 * used / (capacity or 1)
                if capacity > 4600:
                        self["space_label"].text = "%d / %d MB" % (used, capacity) + " (%.2f%% " % percent + _("of a DUAL layer medium used.") + ")"
                        self["space_bar"].value = int(percent)
@@ -154,7 +163,7 @@ class DVDformatTask(Task):
                self.toolbox = job.toolbox
                self.postconditions.append(DVDformatTaskPostcondition())
                self.setTool("/bin/dvd+rw-format")
-               self.args += [ "/dev/cdroms/cdrom0" ]
+               self.args += [ "/dev/" + harddiskmanager.getCD() ]
                self.end = 1100
 
        def prepare(self):
@@ -198,7 +207,7 @@ class DVDinfoTask(Task):
                self.toolbox = job.toolbox
                self.postconditions.append(DVDinfoTaskPostcondition())
                self.setTool("/bin/dvd+rw-mediainfo")
-               self.args += [ "/dev/cdroms/cdrom0" ]
+               self.args += [ "/dev/" + harddiskmanager.getCD() ]
 
        def prepare(self):
                self.error = None