-from Components.Task import Task, Job, job_manager, DiskspacePrecondition, Condition
+from Components.Task import Task, Job, job_manager, DiskspacePrecondition, Condition, ToolExistsPrecondition
from Screens.MessageBox import MessageBox
class png2yuvTask(Task):
def run(self, callback, task_progress_changed):
Task.run(self, callback, task_progress_changed)
+ self.container.stdoutAvail.get().remove(self.processStdout)
self.container.dumpToFile(self.dumpFile)
def processStderr(self, data):
- print "[png2yuvTask]", data
-
- def processStdout(self, data):
- pass
+ print "[png2yuvTask]", data[:-1]
class mpeg2encTask(Task):
def __init__(self, job, inputfile, outputfile):
def run(self, callback, task_progress_changed):
Task.run(self, callback, task_progress_changed)
+ self.container.stdoutAvail.get().remove(self.processStdout)
self.container.dumpToFile(self.dumpFile)
self.container.readFromFile(self.inputFile)
def processStderr(self, data):
print "[spumuxTask]", data[:-1]
- def processStdout(self, data):
- pass
-
class MakeFifoNode(Task):
def __init__(self, job, number):
Task.__init__(self, job, "Make FIFO nodes")
self.args += ["-s", sourcefile, link_name]
self.weighting = 10
+class CopyMeta(Task):
+ def __init__(self, job, sourcefile):
+ Task.__init__(self, job, "Copy title meta files")
+ self.setTool("/bin/cp")
+ from os import listdir
+ path, filename = sourcefile.rstrip("/").rsplit("/",1)
+ tsfiles = listdir(path)
+ for file in tsfiles:
+ if file.startswith(filename+"."):
+ self.args += [path+'/'+file]
+ self.args += [self.job.workspace]
+ self.weighting = 10
+
class DemuxTask(Task):
def __init__(self, job, inputfile):
Task.__init__(self, job, "Demux video into ES")
class MplexTaskPostcondition(Condition):
def check(self, task):
+ if task.error == task.ERROR_UNDERRUN:
+ return True
return task.error is None
def getErrorMessage(self, task):
if inputfiles:
self.args += inputfiles
+ def setTool(self, tool):
+ self.cmd = tool
+ self.args = [tool]
+ self.global_preconditions.append(ToolExistsPrecondition())
+ # we don't want the ReturncodePostcondition in this case because for right now we're just gonna ignore the fact that mplex fails with a buffer underrun error on some streams (this always at the very end)
+
def prepare(self):
self.error = None
if self.demux_task:
if line.startswith("**ERROR:"):
if line.find("Frame data under-runs detected") != -1:
self.error = self.ERROR_UNDERRUN
- print "BUFFER UNDERRUN ERROR !!!"
else:
self.error = self.ERROR_UNKNOWN
class BurnTask(Task):
ERROR_MEDIA, ERROR_SIZE, ERROR_WRITE_FAILED, ERROR_DVDROM, ERROR_ISOFS, ERROR_UNKNOWN = range(6)
- def __init__(self, job):
+ def __init__(self, job, extra_args=[]):
Task.__init__(self, job, "burn")
self.weighting = 500
self.postconditions.append(BurnTaskPostcondition())
self.setTool("/bin/growisofs")
volName = self.getASCIIname(job.project.settings.name.getValue())
- self.args += ["-dvd-video", "-dvd-compat", "-Z", "/dev/cdroms/cdrom0", "-V", volName, "-P", "Dreambox", "-use-the-force-luke=dummy", self.job.workspace + "/dvd"]
+ self.args += ["-dvd-compat", "-Z", "/dev/cdroms/cdrom0", "-V", volName, "-P", "Dreambox", "-use-the-force-luke=dummy", self.job.workspace + "/dvd"]
+ self.args += extra_args
def getASCIIname(self, name):
ASCIIname = ""
return template.decode("utf-8")
def CreateMenus(job):
- import os, Image, ImageDraw, ImageFont
+ try:
+ from ImageFont import truetype
+ import ImageDraw, Image, os
+ except ImportError:
+ job.project.session.open(MessageBox, ("missing python-imaging"), type = MessageBox.TYPE_ERROR)
+ if job.project.waitboxref:
+ job.project.waitboxref.close()
+ return False
+
imgwidth = 720
imgheight = 576
s = job.project.settings
fontsizes = s.font_size.getValue()
fontface = s.font_face.getValue()
- font0 = ImageFont.truetype(fontface, fontsizes[0])
- font1 = ImageFont.truetype(fontface, fontsizes[1])
- font2 = ImageFont.truetype(fontface, fontsizes[2])
+ font0 = truetype(fontface, fontsizes[0])
+ font1 = truetype(fontface, fontsizes[1])
+ font2 = truetype(fontface, fontsizes[2])
color_headline = tuple(s.color_headline.getValue())
color_button = tuple(s.color_button.getValue())
menuoutputfilename = job.workspace+"/dvdmenu"+str(menu_count)+".mpg"
spumuxTask(job, spuxmlfilename, menubgmpgfilename, menuoutputfilename)
+ return True
def CreateAuthoringXML(job):
nr_titles = len(job.project.titles)
def conduct(self):
if self.project.settings.authormode.getValue().startswith("menu") or self.menupreview:
- CreateMenus(self)
+ if not CreateMenus(self):
+ return
CreateAuthoringXML(self)
totalsize = 50*1024*1024 # require an extra safety 50 MB
RemoveESFiles(self, demux)
WaitForResidentTasks(self)
PreviewTask(self)
- BurnTask(self)
+ BurnTask(self,["-dvd-video"])
+ RemoveDVDFolder(self)
+
+class DVDdataJob(Job):
+ def __init__(self, project):
+ Job.__init__(self, "Data DVD Burn")
+ self.project = project
+ from time import strftime
+ from Tools.Directories import SCOPE_HDD, resolveFilename, createDir
+ new_workspace = resolveFilename(SCOPE_HDD) + "tmp/" + strftime("%Y%m%d%H%M%S") + "/dvd/"
+ createDir(new_workspace, True)
+ self.workspace = new_workspace
+ self.project.workspace = self.workspace
+ self.conduct()
+
+ def conduct(self):
+ diskSpaceNeeded = 50*1024*1024 # require an extra safety 50 MB
+ for title in self.project.titles:
+ diskSpaceNeeded += title.filesize
+ nr_titles = len(self.project.titles)
+
+ for self.i in range(nr_titles):
+ title = self.project.titles[self.i]
+ filename = title.inputfile.rstrip("/").rsplit("/",1)[1]
+ link_name = self.workspace + filename
+ LinkTS(self, title.inputfile, link_name)
+ CopyMeta(self, title.inputfile)
+ BurnTask(self)
RemoveDVDFolder(self)
def Burn(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