def inject_openpype_environment(deadlinePlugin): job = deadlinePlugin.GetJob() job = RepositoryUtils.GetJob(job.JobId, True) # invalidates cache print("inject_openpype_environment start") try: exe_list = job.GetJobExtraInfoKeyValue("openpype_executables") openpype_app = FileUtils.SearchFileList(exe_list) if openpype_app == "": raise RuntimeError( "OpenPype executable was not found " + "in the semicolon separated list \"" + exe_list + "\". " + "The path to the render executable can be configured " + "from the Plugin Configuration in the Deadline Monitor.") # tempfile.TemporaryFile cannot be used because of locking export_url = os.path.join(tempfile.gettempdir(), time.strftime('%Y%m%d%H%M%S'), 'env.json') # add HHMMSS + delete later print("export_url {}".format(export_url)) args = [openpype_app, 'extractenvironments', export_url] add_args = {} add_args['project'] = \ job.GetJobEnvironmentKeyValue('AVALON_PROJECT') add_args['asset'] = job.GetJobEnvironmentKeyValue('AVALON_ASSET') add_args['task'] = job.GetJobEnvironmentKeyValue('AVALON_TASK') add_args['app'] = job.GetJobEnvironmentKeyValue('AVALON_APP_NAME') if all(add_args.values()): for key, value in add_args.items(): args.append("--{}".format(key)) args.append(value) else: msg = "Required env vars: AVALON_PROJECT, AVALON_ASSET, " + \ "AVALON_TASK, AVALON_APP_NAME" raise RuntimeError(msg) print("args::{}".format(args)) exit_code = subprocess.call(args, shell=True) if exit_code != 0: raise RuntimeError("Publishing failed, check worker's log") with open(export_url) as fp: contents = json.load(fp) for key, value in contents.items(): deadlinePlugin.SetEnvironmentVariable(key, value) os.remove(export_url) print("inject_openpype_environment end") except Exception: import traceback print(traceback.format_exc()) print("inject_openpype_environment failed") RepositoryUtils.FailJob(job) raise
def __main__(deadlinePlugin): job = deadlinePlugin.GetJob() job = RepositoryUtils.GetJob(job.JobId, True) # invalidates cache openpype_render_job = \ job.GetJobEnvironmentKeyValue('OPENPYPE_RENDER_JOB') or '0' openpype_publish_job = \ job.GetJobEnvironmentKeyValue('OPENPYPE_PUBLISH_JOB') or '0' if openpype_publish_job == '1' and openpype_render_job == '1': raise RuntimeError("Misconfiguration. Job couldn't be both " + "render and publish.") if openpype_publish_job == '1': print("Publish job, skipping inject.") return elif openpype_render_job == '1': inject_openpype_environment(deadlinePlugin) else: pype(deadlinePlugin) # backward compatibility with Pype2
def process(job_ids, priority): jobIds = parse_job_ids(job_ids) if not jobIds: scriptDialog.ShowMessageBox("Empty Job List!", "Error") return jobs = list() for jobId in jobIds: job = RepositoryUtils.GetJob(jobId, True) if job is None: scriptDialog.ShowMessageBox("Job not found: %s" % jobId, "Error") return jobs.append(job) for job in jobs: job.JobPriority = priority RepositoryUtils.SaveJob(job) return True
def process(frames): frame_nums = parse_frames(frames) if not frame_nums: scriptDialog.ShowMessageBox("Empty Frame List!", "Error") return jobIds = MonitorUtils.GetSelectedJobIds() for jobId in jobIds: job = RepositoryUtils.GetJob(jobId, True) tasks = RepositoryUtils.GetJobTasks(job, True) resume = list() for task in tasks: if task.TaskStatus != "Suspended": continue task_frames = set(task.TaskFrameList) if frame_nums.intersection(task_frames): resume.append(task) RepositoryUtils.ResumeTasks(job, resume) return True