incorporate new class to support own asynchronous implementation of a "popen" system...
[enigma2.git] / lib / python / Plugins / Extensions / DVDBurn / DVDToolbox.py
index 30487b690ff1c88a1f3345d9fdde7f9c9cec0960..c0cec2197e936e3b306868b7cd4935f97983a5b2 100644 (file)
@@ -26,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"))
@@ -43,7 +42,7 @@ class DVDToolbox(Screen):
                self["details"] = ScrollLabel()
                self["info"] = StaticText()
 
-               self["toolboxactions"] = ActionMap(["ColorActions", "DVDToolbox"],
+               self["toolboxactions"] = ActionMap(["ColorActions", "DVDToolbox", "OkCancelActions"],
                {
                    "red": self.close,
                    "green": self.update,
@@ -69,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 = ""
@@ -96,11 +95,14 @@ class DVDToolbox(Screen):
                                        capacity = used
                                        used = 0
                        elif line.find("Free Blocks:") > -1:
-                               size = line[15:-3].split('*')
-                               size = int(size[0])*int(size[1])*1024
+                               try:
+                                       size = eval(line[14:].replace("KB","*1024"))
+                               except:
+                                       size = 0
                                if size > 0:
-                                       capacity = size
-                                       used = capacity-used                            
+                                       capacity = size / 1048576
+                                       if used:
+                                               used = capacity-used
                                        print "[free blocks] capacity=%d, used=%d" % (capacity, used)
                        infotext += line
                self["details"].setText(infotext)
@@ -162,7 +164,7 @@ class DVDformatTask(Task):
                self.toolbox = job.toolbox
                self.postconditions.append(DVDformatTaskPostcondition())
                self.setTool("/bin/dvd+rw-format")
-               self.args += [ harddiskmanager.getCD() ]
+               self.args += [ "/dev/" + harddiskmanager.getCD() ]
                self.end = 1100
 
        def prepare(self):
@@ -206,7 +208,7 @@ class DVDinfoTask(Task):
                self.toolbox = job.toolbox
                self.postconditions.append(DVDinfoTaskPostcondition())
                self.setTool("/bin/dvd+rw-mediainfo")
-               self.args += [ harddiskmanager.getCD() ]
+               self.args += [ "/dev/" + harddiskmanager.getCD() ]
 
        def prepare(self):
                self.error = None