From eded0db3bc821a1633da2fd33cf0019407dd1089 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 29 Jul 2009 10:12:31 +0200 Subject: add getSize convenience function to obtain file or directory size (not tested with directories containing lots of files) --- lib/python/Tools/Directories.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/python') diff --git a/lib/python/Tools/Directories.py b/lib/python/Tools/Directories.py index f9394978..aaa2a9da 100755 --- a/lib/python/Tools/Directories.py +++ b/lib/python/Tools/Directories.py @@ -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 -- cgit v1.2.3 From 5d441513d7c81c7e52399801dd34c97480f4e136 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 29 Jul 2009 10:24:08 +0200 Subject: change disc size determination and tweak dual layer growisofs arguments --- .../Plugins/Extensions/DVDBurn/DVDProject.py | 10 +++++++++ lib/python/Plugins/Extensions/DVDBurn/Process.py | 13 +++++++++-- lib/python/Plugins/Extensions/DVDBurn/TitleList.py | 26 +++++++++------------- .../Plugins/Extensions/DVDBurn/TitleProperties.py | 2 +- 4 files changed, 33 insertions(+), 18 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py b/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py index 96fc380a..9a3bd64c 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py @@ -18,6 +18,8 @@ class ConfigFilename(ConfigText): return ("mtext"[1-selected:], filename, mark) class DVDProject: + MAX_SL = 4370 + MAX_DL = 7950 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() diff --git a/lib/python/Plugins/Extensions/DVDBurn/Process.py b/lib/python/Plugins/Extensions/DVDBurn/Process.py index 80e5899b..44075d64 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/Process.py +++ b/lib/python/Plugins/Extensions/DVDBurn/Process.py @@ -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) diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py index fd4c7134..aeb163f3 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py @@ -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,22 @@ 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 + if size > self.project.MAX_DL: + percent = 100 * size / float(self.project.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 < self.project.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 > self.project.MAX_SL: + percent = 100 * size / float(self.project.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 < self.project.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 < self.project.MAX_SL: + percent = 100 * size / float(self.project.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 diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py index 1c2099fb..86d21c25 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py @@ -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) -- cgit v1.2.3 From ed817937df0a68c0b222a4e48fdf24984d87c2fb Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 29 Jul 2009 14:08:29 +0200 Subject: fix disc size unit confusion --- lib/python/Plugins/Extensions/DVDBurn/DVDProject.py | 4 ++-- lib/python/Plugins/Extensions/DVDBurn/TitleList.py | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py b/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py index 9a3bd64c..83672460 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py @@ -18,8 +18,8 @@ class ConfigFilename(ConfigText): return ("mtext"[1-selected:], filename, mark) class DVDProject: - MAX_SL = 4370 - MAX_DL = 7950 + MAX_SL = 4480 + MAX_DL = 8150 def __init__(self): self.titles = [ ] self.target = None diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py index aeb163f3..83bafd74 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py @@ -245,21 +245,24 @@ class TitleList(Screen, HelpableScreen): self["key_yellow"].text = "" def updateSize(self): - size = self.project.size - if size > self.project.MAX_DL: - percent = 100 * size / float(self.project.MAX_DL) + 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 < self.project.MAX_DL: + if self.previous_size < MAX_DL: self.session.open(MessageBox,text = _("exceeds dual layer medium!"), type = MessageBox.TYPE_ERROR) - elif size > self.project.MAX_SL: - percent = 100 * size / float(self.project.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 < self.project.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 < self.project.MAX_SL: - percent = 100 * size / float(self.project.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 -- cgit v1.2.3