def __init__(self, job, inputfile): Task.__init__(self, job, "Demux video into ES") title = job.project.titles[job.i] self.global_preconditions.append(DiskspacePrecondition(title.estimatedDiskspace)) self.setTool("projectx") self.args += [ inputfile, "-demux", "-set", "ExportPanel.Streamtype.Subpicture=0", "-set", "ExportPanel.Streamtype.Teletext=0", "-out", self.job.workspace, ] self.end = 300 self.prog_state = 0 self.weighting = 1000 self.cutfile = self.job.workspace + "/cut_%d.Xcl" % (job.i + 1) self.cutlist = title.cutlist self.currentPID = None self.relevantAudioPIDs = [] self.getRelevantAudioPIDs(title) self.generated_files = [] self.mplex_audiofiles = {} self.mplex_videofile = "" self.mplex_streamfiles = [] if len(self.cutlist) > 1: self.args += ["-cut", self.cutfile]
def __init__(self, job, cmdline, srcfile, destfile, name): Task.__init__(self, job, name) self.setCmdline(cmdline) self.srcfile = srcfile self.destfile = destfile self.ProgressTimer = eTimer() self.ProgressTimer.callback.append(self.ProgressUpdate)
def downloadFailed(self, failure_instance=None, error_message=''): print '[YouTube] Video download failed' if error_message == '' and failure_instance is not None: error_message = failure_instance.getErrorMessage() print '[YouTube]', str(error_message) Task.processFinished(self, 1) self.downloadStop()
def __init__(self, job, device, mountpoint): Task.__init__(self, job, ("mount")) self.setTool("mount") options = "rw,sync" self.mountpoint = mountpoint self.args += [ device, mountpoint, "-o"+options ] self.weighting = 1
def run(self, callback): self.callback = callback try: self.conduct() Task.processFinished(self, 0) except Exception: Task.processFinished(self, 1)
def __init__(self, job, title, mpls_num): Task.__init__(self, job, "Create BDMV Playlist File") self.title = title self.mpls_num = mpls_num self.job = job self.weighting = 10 self.postconditions.append(GenericPostcondition())
def __init__(self, job, sourcefile, title_no): Task.__init__(self, job, "Copy thumbnail") self.setTool("cp") source = sourcefile.rsplit('.',1)[0] + ".png" dest = self.job.workspace+'BDMV/META/DL/thumb_%05d.png' % title_no self.args += [source, dest] self.weighting = 10
def __init__(self, job, title, clip_num): Task.__init__(self, job, "Create BDMV Clip Info File") self.title = title self.clip_num = clip_num self.job = job self.weighting = 10 self.postconditions.append(GenericPostcondition())
def conduct(self): from Tools.XMLTools import stringToXML dl = ['<?xml version="1.0" encoding="utf-8" ?>'] dl.append('<disclib xmlns="urn:BDA:bdmv;disclib" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:BDA:bdmv;disclib disclib.xsd">') dl.append('\t<di:discinfo xmlns:di="urn:BDA:bdmv;discinfo">') dl.append(strftime("\t<di:date>%Y-%m-%d</di:date>")) dl.append('\t\t<di:creator>Dream Multimedia Enigma2</di:creator>') dl.append('\t\t<di:title>') dl.append('\t\t\t<di:name>'+stringToXML(self.project.settings.name.value)+'</di:name>') dl.append('\t\t\t<di:numSets>1</di:numSets>') dl.append('\t\t\t<di:setNumber>1</di:setNumber>') dl.append('\t\t</di:title>') dl.append('\t\t<di:description>') dl.append('\t\t\t<di:tableOfContents>') for title_no, title in enumerate(self.job.titles): dl.append('\t\t\t\t<di:titleName titleNumber="%d">%s</di:titleName>' % (title_no, stringToXML(title.properties.menutitle.value))) dl.append('\t\t\t</di:tableOfContents>') for title_no in range(len(self.job.titles)): dl.append('\t\t\t<di:thumbnail href="thumb_%05d.png" />' % title_no) dl.append('\t\t</di:description>') dl.append('\t\t<di:language>'+stringToXML(self.languageCode)+'</di:language>') dl.append('\t</di:discinfo>') dl.append('</disclib>') filename = self.job.workspace+'BDMV/META/DL/bdmt_%s.xml' % self.languageCode try: file = open(filename, "w") for line in dl: file.write(line+'\n') file.close() except: Task.processFinished(self, 1) Task.processFinished(self, 0) self.project.finished_burning = True
def __init__(self, job, project): Task.__init__(self, job, "Create BDMV Meta Info Files") self.project = project self.job = job self.weighting = 10 self.postconditions.append(GenericPostcondition()) self.languageCode = iso639language.get_dvd_id(self.project.menutemplate.settings.menulang.getValue())
def processOutput(self, data): print "[DVDformatTask processOutput] ", data if data.endswith("%"): data = data.replace("\x08", "") self.progress = int(float(data[:-1]) * 10) else: Task.processOutput(self, data)
def __init__(self, job, extra_args=[], tool="growisofs"): Task.__init__(self, job, job.name) self.weighting = 500 self.end = 120 # 100 for writing, 10 for buffer flush, 10 for closing disc self.postconditions.append(BurnTaskPostcondition()) self.setTool(tool) self.args += extra_args
def __init__(self, job): Task.__init__(self, job, "Authoring DVD") self.weighting = 20 self.setTool("dvdauthor") self.CWD = self.job.workspace self.args += ["-x", self.job.workspace+"/dvdauthor.xml"] self.menupreview = job.menupreview
def __init__(self, job, xmlfile, inputfile, outputfile): Task.__init__(self, job, "Muxing buttons into menu") self.setTool("spumux") self.args += [xmlfile] self.inputFile = inputfile self.dumpFile = outputfile self.weighting = 15
def run(self, callback): self.callback = callback failed_preconditions = self.checkPreconditions(True) + self.checkPreconditions(False) if len(failed_preconditions): callback(self, failed_preconditions) return Task.processFinished(self, 0)
def __init__(self, job, url, fileName, agent=None): print "[DownloadTask] url='%s', fileName='%s'" %(url, fileName) Task.__init__(self, job, ("download task")) self.agent = agent self.end = 100 self.url = url self.local = fileName
def __init__(self, job, src_file, dst_file, src_isDir, do_copy): Task.__init__(self, job, '') nice = 'ionice -c 3' self.src_isDir = src_isDir self.src_file = src_file self.dst_isDir = False self.dst_file = dst_file + '/' + os.path.basename(src_file) src_file_append = '' if not src_isDir: src_file_fields = src_file.rsplit('.', 1) if len(src_file_fields): src_file = src_file_fields[0] + '.' src_file_append = '*' cmd = 'mv' if do_copy: cmd = 'cp -pr' cmdline = '%s %s "%s"%s "%s"' % (nice, cmd, src_file, src_file_append, dst_file) if self.dst_file.endswith('/'): self.dst_isDir = True self.setCmdline(cmdline) self.end = 100 self.progressTimer = eTimer() self.progressTimer.callback.append(self.progressUpdate)
def __init__(self, job, cmdline, srcfile, destfile, eventname): Task.__init__(self, job, eventname) self.toolbox = job.toolbox self.setCmdline(cmdline) self.srcfile = config.usage.timeshift_path.value + srcfile + '.copy' self.destfile = destfile + '.ts' self.ProgressTimer = eTimer() self.ProgressTimer.callback.append(self.ProgressUpdate)
def __init__(self, job, cmdline, filename, filetitle): Task.__init__(self, job, filetitle) # self.postconditions.append(downloadTaskPostcondition()) self.setCmdline(cmdline) self.filename = filename self.toolbox = job.toolbox self.error = None self.lasterrormsg = None
def __init__(self, job, path, md5): Task.__init__(self, job, "md5sum") self.postconditions.append(md5Postcondition()) self.weighting = 5 self.cwd = path self.setTool("md5sum") self.args += ["-c", "-s"] self.initial_input = md5
def __init__(self, job, extra_args=[]): Task.__init__(self, job, ("RW medium format")) self.toolbox = job.toolbox self.postconditions.append(DVDformatTaskPostcondition()) self.setTool("dvd+rw-format") self.args += [ "/dev/" + harddiskmanager.getCD() ] self.end = 1100 self.retryargs = [ ]
def __init__(self, job, cmdline, srcfile, destfile, eventname): Task.__init__(self, job, eventname) self.toolbox = job.toolbox self.setCmdline(cmdline) self.srcfile = config.usage.autorecord_path.value + srcfile self.destfile = config.usage.autorecord_path.value + destfile self.ProgressTimer = eTimer() self.ProgressTimer.callback.append(self.ProgressUpdate)
def __init__(self, job): Task.__init__(self, job, ("partitioning")) self.postconditions.append(PartitionTaskPostcondition()) self.job = job self.setTool("sfdisk") self.args += [self.job.device] self.weighting = 10 self.initial_input = "0 - 0x6 *\n;\n;\n;\ny" self.errormsg = ""
def __init__(self, job): Task.__init__(self, job, ("Unpacking USB flasher image...")) self.job = job self.setTool("tar") self.args += ["-xjvf", self.job.downloadfilename] self.weighting = 80 self.end = 80 self.delayTimer = eTimer() self.delayTimer.callback.append(self.progress_increment)
def __init__(self, job): Task.__init__(self, job, ("Copying USB flasher boot image to stick...")) self.job = job self.setTool("dd") self.args += ["if=%s" % self.job.imagefilename, "of=%s1" % self.job.device] self.weighting = 20 self.end = 20 self.delayTimer = eTimer() self.delayTimer.callback.append(self.progress_increment)
def __init__(self, job, param, box): Task.__init__(self, job, ("Writing image file to NAND Flash")) self.setTool(eEnv.resolve("${libdir}/enigma2/python/Plugins/SystemPlugins/NFIFlash/writenfi-mipsel-2.6.18-r1")) if box == "dm7025": self.end = 256 elif box[:5] == "dm800": self.end = 512 self.args += param self.weighting = 95
def __init__(self, job, outputfile, inputfiles=None, demux_task=None, weighting = 500): Task.__init__(self, job, "Mux ES into PS") self.weighting = weighting self.demux_task = demux_task self.postconditions.append(MplexTaskPostcondition()) self.setTool("mplex") self.args += ["-f8", "-o", outputfile, "-v1"] if inputfiles: self.args += inputfiles
def downloadFinished(self, result): Task.processFinished(self, 0) self.downloadStop() if '_suburi.mp4' in self.outputfile and \ config.plugins.YouTube.mergeFiles.value and \ os.path.exists('%s.m4a' % self.outputfile[:-11]) and \ not os.path.exists('%s.mkv' % self.outputfile[:-11]): from Components.Console import Console Console().ePopen('ffmpeg -i "%s" -i "%s.m4a" -c copy "%s.mkv"' % (self.outputfile, self.outputfile[:-11], self.outputfile[:-11]), self.mergeCompleted)
def __init__(self, job, menu_count, spuxmlfilename, menubgpngfilename, highlightpngfilename): Task.__init__(self, job, "Create Menu %d Image" % menu_count) self.postconditions.append(ImagingPostcondition()) self.weighting = 10 self.job = job self.Menus = job.Menus self.menu_count = menu_count self.spuxmlfilename = spuxmlfilename self.menubgpngfilename = menubgpngfilename self.highlightpngfilename = highlightpngfilename
def __init__(self, job, sourcefile): Task.__init__(self, job, "Copy title meta files") self.setTool("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 = 15
def do_run_script(self, answer): answer = answer and answer[1] if answer in ("YES", "PAR", "YES_BG", "PAR_BG"): if not os.access(self.commando, os.R_OK): self.session.open( MessageBox, _("Script '%s' must have read permission to be able to run it" ) % self.commando, type=MessageBox.TYPE_ERROR, close_on_any_key=True, simple=True) return nice = config.plugins.filecommander.script_priority_nice.getValue( ) or '' ionice = config.plugins.filecommander.script_priority_ionice.getValue( ) or '' if nice: nice = 'nice -n %d ' % nice if ionice: ionice = 'ionice -c %d ' % ionice priority = '%s%s' % (nice, ionice) if self.commando.endswith('.sh'): if os.access(self.commando, os.X_OK): if 'PAR' in answer: cmdline = "%s%s '%s'" % (priority, self.commando, self.parameter) else: cmdline = "%s%s" % (priority, self.commando) else: if 'PAR' in answer: cmdline = "%s/bin/sh %s '%s'" % ( priority, self.commando, self.parameter) else: cmdline = "%s/bin/sh %s" % (priority, self.commando) else: if 'PAR' in answer: cmdline = "%s/usr/bin/python %s '%s'" % ( priority, self.commando, self.parameter) else: cmdline = "%s/usr/bin/python %s" % (priority, self.commando) elif answer == "VIEW": try: yfile = os.stat(self.commando) except OSError as oe: self.session.open(MessageBox, _("%s: %s") % (self.commando, oe.strerror), type=MessageBox.TYPE_ERROR, simple=True) return if (yfile.st_size < 1000000): self.session.open(vEditor, self.commando) if answer and answer not in ("NO", "VIEW"): if answer.endswith('_BG'): global task_Stout, task_Sterr task_Stout = [] task_Sterr = [] if 'PAR' in answer: name = '%s%s %s' % (priority, self.commando, self.parameter) else: name = '%s%s' % (priority, self.commando) job = Job(_("Run script") + " ('%s')" % name) task = Task(job, name) task.postconditions.append(task_postconditions()) task.processStdout = task_processStdout task.processStderr = task_processSterr task.setCmdline(cmdline) job_manager.AddJob(job, onSuccess=self.finishedCB, onFail=self.failCB) self.jobs += 1 self.onLayout() else: self.session.open(Console, cmdlist=(cmdline, ))
def __init__(self, job, outputfile, inputfile): Task.__init__(self, job, "ReMux TS into PS") self.weighting = 1000 self.setTool("replex") self.args += ["-t", "DVD", "-j", "-o", outputfile, inputfile]
def closedCB(self, answer): if answer == True: Task.processFinished(self, 0) else: Task.processFinished(self, 1)
def __init__(self, job): Task.__init__(self, job, _("please wait, loading picture...")) self.postconditions.append(ImagingPostcondition()) self.weighting = 20 self.job = job self.Menus = job.Menus
def download_finished(self, string=""): if self.aborted: self.finish(aborted=True) else: Task.processFinished(self, 0)
def run(self, callback): Task.run(self, callback)
def run(self, callback): Task.run(self, callback) self.delayTimer.start(100, False)
def __init__(self, job, inputfile, outputfile): Task.__init__(self, job, "Encoding menu video") self.setTool("mpeg2enc") self.args += ["-f8", "-np", "-a2", "-o", outputfile] self.inputFile = inputfile self.weighting = 25
def __init__(self, job, cmdline, eventname): Task.__init__(self, job, eventname) self.toolbox = job.toolbox self.setCmdline(cmdline)
def __init__(self, job, sourcefile, link_name): Task.__init__(self, job, "Creating symlink for source titles") self.setTool("ln") self.args += ["-s", sourcefile, link_name] self.weighting = 10
def download_failed(self, failure_instance=None, error_message=""): self.error_message = error_message if error_message == "" and failure_instance is not None: self.error_message = failure_instance.getErrorMessage() Task.processFinished(self, 1)
def __init__(self, job): Task.__init__(self, job, "Remove temp. files") self.setTool("rm") self.args += ["-rf", self.job.workspace] self.weighting = 10
def __init__(self, job, path): Task.__init__(self, job, "Preview") self.postconditions.append(PreviewTaskPostcondition()) self.job = job self.path = path self.weighting = 10
def __init__(self, job, mountpoint): Task.__init__(self, job, ("mount")) self.setTool("umount") self.args += [mountpoint] self.weighting = 1
def __init__(self, job): Task.__init__(self, job, "waiting for dvdauthor to finalize")
def run(self, callback): Task.run(self, callback) self.container.readFromFile(self.inputFile)
def __init__(self, job): Task.__init__(self, job, "dvdauthor finalize") self.setTool("dvdauthor") self.args += ["-T", "-o", self.job.workspace + "/dvd"]
def __init__(self, job, number): Task.__init__(self, job, "Make FIFO nodes") self.setTool("mknod") nodename = self.job.workspace + "/dvd_title_%d" % number + ".mpg" self.args += [nodename, "p"] self.weighting = 10
def run(self, callback): self.callback = callback #try: import ImageDraw import Image import os s = self.job.project.menutemplate.settings s_top = s.margin_top.getValue() s_bottom = s.margin_bottom.getValue() s_left = s.margin_left.getValue() s_right = s.margin_right.getValue() s_rows = s.space_rows.getValue() s_cols = s.space_cols.getValue() nr_cols = s.cols.getValue() nr_rows = s.rows.getValue() thumb_size = s.thumb_size.getValue() if thumb_size[0]: from Image import open as Image_open (s_width, s_height) = s.dimensions.getValue() fonts = self.Menus.fonts im_bg = self.Menus.im_bg_orig.copy() im_high = Image.new("P", (s_width, s_height), 0) im_high.putpalette(self.Menus.spu_palette) draw_bg = ImageDraw.Draw(im_bg) draw_high = ImageDraw.Draw(im_high) if self.menu_count == 1: headlineText = self.job.project.settings.name.getValue().decode("utf-8") headlinePos = self.getPosition(s.offset_headline.getValue(), 0, 0, s_width, s_top, draw_bg.textsize(headlineText, font=fonts[0])) draw_bg.text(headlinePos, headlineText, fill=self.Menus.color_headline, font=fonts[0]) spuxml = """<?xml version="1.0" encoding="utf-8"?> <subpictures> <stream> <spu highlight="%s" transparent="%02x%02x%02x" start="00:00:00.00" force="yes" >""" % (self.highlightpngfilename, self.Menus.spu_palette[0], self.Menus.spu_palette[1], self.Menus.spu_palette[2]) #rowheight = (self.Menus.fontsizes[1]+self.Menus.fontsizes[2]+thumb_size[1]+s_rows) menu_start_title = (self.menu_count - 1) * self.job.titles_per_menu + 1 menu_end_title = (self.menu_count) * self.job.titles_per_menu + 1 nr_titles = len(self.job.project.titles) if menu_end_title > nr_titles: menu_end_title = nr_titles + 1 col = 1 row = 1 for title_no in list(range(menu_start_title, menu_end_title)): title = self.job.project.titles[title_no - 1] col_width = (s_width - s_left - s_right) / nr_cols row_height = (s_height - s_top - s_bottom) / nr_rows left = s_left + ((col - 1) * col_width) + s_cols / 2 right = left + col_width - s_cols top = s_top + ((row - 1) * row_height) + s_rows / 2 bottom = top + row_height - s_rows width = right - left height = bottom - top if bottom > s_height: bottom = s_height #draw_bg.rectangle((left, top, right, bottom), outline=(255,0,0)) im_cell_bg = Image.new("RGBA", (width, height), (0, 0, 0, 0)) draw_cell_bg = ImageDraw.Draw(im_cell_bg) im_cell_high = Image.new("P", (width, height), 0) im_cell_high.putpalette(self.Menus.spu_palette) draw_cell_high = ImageDraw.Draw(im_cell_high) if thumb_size[0]: thumbPos = self.getPosition(s.offset_thumb.getValue(), 0, 0, width, height, thumb_size) box = (thumbPos[0], thumbPos[1], thumbPos[0] + thumb_size[0], thumbPos[1] + thumb_size[1]) try: thumbIm = Image_open(title.inputfile.rsplit('.', 1)[0] + ".png") im_cell_bg.paste(thumbIm, thumbPos) except: draw_cell_bg.rectangle(box, fill=(64, 127, 127, 127)) border = s.thumb_border.getValue() if border: draw_cell_high.rectangle(box, fill=1) draw_cell_high.rectangle((box[0] + border, box[1] + border, box[2] - border, box[3] - border), fill=0) titleText = title.formatDVDmenuText(s.titleformat.getValue(), title_no).decode("utf-8") titlePos = self.getPosition(s.offset_title.getValue(), 0, 0, width, height, draw_bg.textsize(titleText, font=fonts[1])) draw_cell_bg.text(titlePos, titleText, fill=self.Menus.color_button, font=fonts[1]) draw_cell_high.text(titlePos, titleText, fill=1, font=self.Menus.fonts[1]) subtitleText = title.formatDVDmenuText(s.subtitleformat.getValue(), title_no).decode("utf-8") subtitlePos = self.getPosition(s.offset_subtitle.getValue(), 0, 0, width, height, draw_cell_bg.textsize(subtitleText, font=fonts[2])) draw_cell_bg.text(subtitlePos, subtitleText, fill=self.Menus.color_button, font=fonts[2]) del draw_cell_bg del draw_cell_high im_bg.paste(im_cell_bg, (left, top, right, bottom), mask=im_cell_bg) im_high.paste(im_cell_high, (left, top, right, bottom)) spuxml += """ <button name="button%s" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (str(title_no).zfill(2), left, right, top, bottom) if col < nr_cols: col += 1 else: col = 1 row += 1 top = s_height - s_bottom - s_rows / 2 if self.menu_count < self.job.nr_menus: next_page_text = s.next_page_text.getValue().decode("utf-8") textsize = draw_bg.textsize(next_page_text, font=fonts[1]) pos = (s_width - textsize[0] - s_right, top) draw_bg.text(pos, next_page_text, fill=self.Menus.color_button, font=fonts[1]) draw_high.text(pos, next_page_text, fill=1, font=fonts[1]) spuxml += """ <button name="button_next" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (pos[0], pos[0] + textsize[0], pos[1], pos[1] + textsize[1]) if self.menu_count > 1: prev_page_text = s.prev_page_text.getValue().decode("utf-8") textsize = draw_bg.textsize(prev_page_text, font=fonts[1]) pos = ((s_left + s_cols / 2), top) draw_bg.text(pos, prev_page_text, fill=self.Menus.color_button, font=fonts[1]) draw_high.text(pos, prev_page_text, fill=1, font=fonts[1]) spuxml += """ <button name="button_prev" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (pos[0], pos[0] + textsize[0], pos[1], pos[1] + textsize[1]) del draw_bg del draw_high fd = open(self.menubgpngfilename, "w") im_bg.save(fd, "PNG") fd.close() fd = open(self.highlightpngfilename, "w") im_high.save(fd, "PNG") fd.close() spuxml += """ </spu> </stream> </subpictures>""" f = open(self.spuxmlfilename, "w") f.write(spuxml) f.close() Task.processFinished(self, 0)
def run(self, callback): self.callback = callback self.conduct() Task.processFinished(self, 0)
def run(self, callback): Task.run(self, callback) self.container.stdoutAvail.remove(self.processStdout) self.container.dumpToFile(self.dumpFile)
def __init__(self, job, demux_task): Task.__init__(self, job, "Remove temp. files") self.demux_task = demux_task self.setTool("rm") self.weighting = 10
def conduct(self): for directory in ['BDMV', 'BDMV/AUXDATA', 'BDMV/BACKUP', 'BDMV/BACKUP/BDJO', 'BDMV/BACKUP/CLIPINF', 'BDMV/BACKUP/JAR', 'BDMV/BACKUP/PLAYLIST', 'BDMV/BDJO', 'BDMV/CLIPINF', 'BDMV/JAR', 'BDMV/META', 'BDMV/META/DL', 'BDMV/PLAYLIST', 'BDMV/STREAM']: if not createDir(self.job.workspace + directory): Task.processFinished(self, 1)
def __init__(self, job, inputfile, outputfile): Task.__init__(self, job, "Creating menu video") self.setTool("png2yuv") self.args += ["-n1", "-Ip", "-f25", "-j", inputfile] self.dumpFile = outputfile self.weighting = 15
def __init__(self, job): Task.__init__(self, job, "Creating BDMV Directory Structure") self.job = job self.weighting = 10 self.postconditions.append(GenericPostcondition())
def __init__(self, job): Task.__init__(self, job, "Create BDMV Movie Objects File") self.job = job self.weighting = 10 self.postconditions.append(GenericPostcondition())