Merge branch 'master' of git.opendreambox.org:/git/enigma2
authorghost <andreas.monzner@multimedia-labs.de>
Thu, 30 Jul 2009 10:07:43 +0000 (12:07 +0200)
committerghost <andreas.monzner@multimedia-labs.de>
Thu, 30 Jul 2009 10:07:43 +0000 (12:07 +0200)
lib/python/Plugins/Extensions/DVDBurn/DVDProject.py
lib/python/Plugins/Extensions/DVDBurn/Process.py
lib/python/Plugins/Extensions/DVDBurn/TitleList.py
lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py
lib/python/Tools/Directories.py

index 96fc380..8367246 100644 (file)
@@ -18,6 +18,8 @@ class ConfigFilename(ConfigText):
                return ("mtext"[1-selected:], filename, mark)
        
 class DVDProject:
+       MAX_SL = 4480
+       MAX_DL = 8150
        def __init__(self):
                self.titles = [ ]
                self.target = None
@@ -140,6 +142,14 @@ class DVDProject:
                        return False
                return True
 
+       def getSize(self):
+               totalsize = 0
+               for title in self.titles:
+                       totalsize += title.estimatedDiskspace
+               return totalsize
+
+       size = property(getSize)
+
 class MenuTemplate(DVDProject):
        def __init__(self):
                self.settings = ConfigSubsection()
index 80e5899..44075d6 100644 (file)
@@ -315,9 +315,9 @@ class BurnTask(Task):
                elif line.startswith(":-["):
                        if line.find("ASC=30h") != -1:
                                self.error = self.ERROR_NOTWRITEABLE
-                       if line.find("ASC=24h") != -1:
+                       elif line.find("ASC=24h") != -1:
                                self.error = self.ERROR_LOAD
-                       if line.find("SK=5h/ASC=A8h/ACQ=04h") != -1:
+                       elif line.find("SK=5h/ASC=A8h/ACQ=04h") != -1:
                                self.error = self.ERROR_MINUSRWBUG
                        else:
                                self.error = self.ERROR_UNKNOWN
@@ -883,6 +883,8 @@ class DVDJob(Job):
                                self.name = _("Burn DVD")
                                tool = "/bin/growisofs"
                                burnargs = [ "-Z", "/dev/" + harddiskmanager.getCD(), "-dvd-compat" ]
+                               if self.project.size/(1024*1024) > self.project.MAX_SL:
+                                       burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ]
                        elif output == "iso":
                                self.name = _("Create DVD-ISO")
                                tool = "/usr/bin/mkisofs"
@@ -921,6 +923,8 @@ class DVDdataJob(Job):
                if output == "dvd":
                        self.name = _("Burn DVD")
                        burnargs = [ "-Z", "/dev/" + harddiskmanager.getCD(), "-dvd-compat" ]
+                       if self.project.size/(1024*1024) > self.project.MAX_SL:
+                               burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ]
                elif output == "iso":
                        tool = "/usr/bin/mkisofs"
                        self.name = _("Create DVD-ISO")
@@ -941,13 +945,18 @@ class DVDisoJob(Job):
                Job.__init__(self, _("Burn DVD"))
                self.project = project
                self.menupreview = False
+               from Tools.Directories import getSize
                if imagepath.endswith(".iso"):
                        PreviewTask(self, imagepath)
                        burnargs = [ "-Z", "/dev/" + harddiskmanager.getCD() + '='+imagepath, "-dvd-compat" ]
+                       if getSize(imagepath)/(1024*1024) > self.project.MAX_SL:
+                               burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ]
                else:
                        PreviewTask(self, imagepath + "/VIDEO_TS/")
                        volName = self.project.settings.name.getValue()
                        burnargs = [ "-Z", "/dev/" + harddiskmanager.getCD(), "-dvd-compat" ]
+                       if getSize(imagepath)/(1024*1024) > self.project.MAX_SL:
+                               burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ]
                        burnargs += [ "-dvd-video", "-publisher", "Dreambox", "-V", volName, imagepath ]
                tool = "/bin/growisofs"
                BurnTask(self, burnargs, tool)
index fd4c713..83bafd7 100644 (file)
@@ -232,13 +232,11 @@ class TitleList(Screen, HelpableScreen):
                
        def updateTitleList(self):
                res = [ ]
-               totalsize = 0
                for title in self.project.titles:
                        a = [ title, (eListboxPythonMultiContent.TYPE_TEXT, 0, 5, 500, 25, 0, RT_HALIGN_LEFT, title.properties.menutitle.getValue())  ]
                        res.append(a)
-                       totalsize += title.estimatedDiskspace
                self["titles"].list = res
-               self.updateSize(totalsize)
+               self.updateSize()
                if len(res):
                        self["key_red"].text = _("Remove title")
                        self["key_yellow"].text = _("Title properties")
@@ -246,24 +244,25 @@ class TitleList(Screen, HelpableScreen):
                        self["key_red"].text = ""
                        self["key_yellow"].text = ""
 
-       def updateSize(self, totalsize):
-               size = int((totalsize/1024)/1024)
-               max_SL = 4370
-               max_DL = 7950
-               if size > max_DL:
-                       percent = 100 * size / float(max_DL)
+       def updateSize(self):
+               size = self.project.size/(1024*1024)
+               MAX_DL = self.project.MAX_DL-100
+               MAX_SL = self.project.MAX_SL-100
+               print "updateSize:", size, "MAX_DL:", MAX_DL, "MAX_SL:", MAX_SL
+               if size > MAX_DL:
+                       percent = 100 * size / float(MAX_DL)
                        self["space_label"].text = "%d MB - " % size + _("exceeds dual layer medium!") + " (%.2f%% " % (100-percent) + _("free") + ")"
                        self["space_bar"].value = int(percent)
-                       if self.previous_size < max_DL:
+                       if self.previous_size < MAX_DL:
                                self.session.open(MessageBox,text = _("exceeds dual layer medium!"), type = MessageBox.TYPE_ERROR)
-               elif size > max_SL:
-                       percent = 100 * size / float(max_DL)
+               elif size > MAX_SL:
+                       percent = 100 * size / float(MAX_DL)
                        self["space_label"].text = "%d MB  " % size + _("of a DUAL layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")"
                        self["space_bar"].value = int(percent)
-                       if self.previous_size < max_SL:
+                       if self.previous_size < MAX_SL:
                                self.session.open(MessageBox,text = _("Your collection exceeds the size of a single layer medium, you will need a blank dual layer DVD!"), type = MessageBox.TYPE_INFO)
-               elif size < max_SL:
-                       percent = 100 * size / float(max_SL)
+               elif size < MAX_SL:
+                       percent = 100 * size / float(MAX_SL)
                        self["space_label"].text = "%d MB " % size + _("of a SINGLE layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")"
                        self["space_bar"].value = int(percent)
                self.previous_size = size
index 1c2099f..86d21c2 100644 (file)
@@ -91,7 +91,7 @@ class TitleProperties(Screen,ConfigListScreen):
                        chaptermarks = title.getChapterMarks(template="$h:$m:$s")
                        chapters_count = len(chaptermarks)
                        if chapters_count >= 1:
-                               infotext += '\n' + str(chapters_count+1) + ' ' + _("chapters") + ': '
+                               infotext += str(chapters_count+1) + ' ' + _("chapters") + ': '
                                infotext += ' / '.join(chaptermarks)
                        self["serviceinfo"].setText(infotext)
                        self["config"].setList(self.list)
index f939497..aaa2a9d 100755 (executable)
@@ -262,3 +262,14 @@ def copytree(src, dst, symlinks=False):
                        utime(dst, (st.st_atime, st.st_mtime))
        except:
                print "copy stats for", src, "failed!"
+
+def getSize(path, pattern=".*"):
+       path_size = 0
+       if os_path.isdir(path):
+               files = crawlDirectory(path, pattern)
+               for file in files:
+                       filepath = os_path.join(file[0], file[1])
+                       path_size += os_path.getsize(filepath)
+       elif os_path.isfile(path):
+               path_size = os_path.getsize(path)
+       return path_size