def worker(): # generate a tempdir for this worker-thread and use the artwork-subdir as temporary folder tempdir = tempfile.mkdtemp() workdir = os.path.join(tempdir, 'artwork') # save the current working dir as output-dir outdir = os.path.join(os.getcwd(), projectname) # print a message that we're about to initialize our environment tprint("initializing worker in {0}, writing result to {1}".format( tempdir, outdir)) # copy the artwork-dir into the tempdir shutil.copytree(os.path.join(projectname, 'artwork'), workdir) # loop until all tasks are done (when the thread fetches a sentinal from the queue) while True: # fetch a task from the queue task = renderlib.Rendertask.ensure(tasks.get()) # if it is a stop-sentinal break out of the loop if task == None: break # print that we're about to render a task tprint('rendering {0} from {1}'.format(task.outfile, task.infile)) # prepend workdir to input file task.infile = os.path.join(workdir, task.infile) task.outfile = os.path.join(outdir, task.outfile) task.workdir = workdir # render with these arguments renderlib.rendertask(task) # print that we're finished tprint('finished {0}, {1} tasks left'.format( task.outfile, max(0, tasks.qsize() - num_worker_threads))) # mark the task as finished tasks.task_done() # all tasks from the queue done, clean up tprint("cleaning up worker") # remove the tempdir shutil.rmtree(tempdir) # mark the sentinal as done tasks.task_done()
def worker(): # generate a tempdir for this worker-thread and use the artwork-subdir as temporary folder tempdir = tempfile.mkdtemp() workdir = os.path.join(tempdir, 'artwork') # save the current working dir as output-dir outdir = os.path.join(os.getcwd(), projectname) # print a message that we're about to initialize our environment tprint("initializing worker in {0}, writing result to {1}".format(tempdir, outdir)) # copy the artwork-dir into the tempdir shutil.copytree(os.path.join(projectname, 'artwork'), workdir) # loop until all tasks are done (when the thread fetches a sentinal from the queue) while True: # fetch a task from the queue task = renderlib.Rendertask.ensure(tasks.get()) # if it is a stop-sentinal break out of the loop if task is None: break # print that we're about to render a task tprint('rendering {0} from {1}'.format(task.outfile, task.infile)) # prepend workdir to input file task.infile = os.path.join(workdir, task.infile) task.outfile = os.path.join(outdir, task.outfile) task.workdir = workdir # render with these arguments renderlib.rendertask(task) # print that we're finished tprint('finished {0}, {1} tasks left'.format(task.outfile, max(0, tasks.qsize() - num_worker_threads))) # mark the task as finished tasks.task_done() # all tasks from the queue done, clean up tprint("cleaning up worker") # remove the tempdir shutil.rmtree(tempdir) # mark the sentinal as done tasks.task_done()
def generatePreroll(ticket): print(ticket) projectname = ticket.get('Processing.Prerolls.Slug', ticket['Meta.Acronym']) if not projectname in projects: projects[projectname] = renderlib.loadProject(projectname) project = projects[projectname] task = project.ticket(ticket) task.outfile = os.path.join(ticket['Processing.Path.Intros'], ticket['Fahrplan.ID'] + '.dv') task.workdir = os.path.join(os.getcwd(), projectname, 'artwork') print(colored("rendering", 'green')) renderlib.rendertask(task) if hasattr(project, 'deploy'): print(colored("deploying", 'green')) project.deploy(ticket, task)
def render(infile, outfile, sequence, parameters={}, workdir=os.path.join(projectname, 'artwork')): task = renderlib.Rendertask(infile=infile, outfile=outfile, sequence=sequence, parameters=parameters, workdir=workdir) return renderlib.rendertask(task)