Hi,
I am trying to write a post job script that deletes the *.ifd files after a job has completed, but I can’t find a snippet that collects the completed tasks.
I’ve hacked this together, but rather than deleting all the IFDs in a folder, I would like to remove the ones specific to the job:
[code]import os
from System.IO import *
from Deadline.Scripting import *
def main(*args):
deadline_plugin = args[0]
job = deadline_plugin.GetJob()
output_directories = job.OutputDirectories
output_filenames = job.OutputFileNames
for i in range(0, len(output_directories)):
output_directory = output_directories[i]
#output_filename = output_filenames[i]
deadline_plugin.LogInfo('Output directory: ' + output_directory)
deadline_plugin.LogInfo('Deleting IFD files:')
files = os.listdir(output_directory)
for f in files:
full_path = os.path.join(output_directory, f)
if not os.path.isdir(f) and '.ifd' in f:
deadline_plugin.LogInfo(full_path)
#os.remove(full_path)[/code]
Is there something like job.CompletedTaskFiles I haven’t found yet? I can’t use the outputFilename since the ifd file is named differently than the image file.
Also, do you know if it is possible to connect an IDE (I use PyCharm) to Deadline’s libraries for autocomplete? I tried pointing it to dpython.exe but it said ‘The selected file is not a valid home for Python SDK’. Could be an PyCharm issue, but I figured I’d ask here too.
You can use RepositoryUtils.GetJobTasks() to get the job’s task collection. Here’s a quick snippet:
job = deadline_plugin.GetJob()
tasks = RepositoryUtils.GetJobTasks( job, True )
for task in tasks:
# do something
Cheers,
Ryan
Thank you for the reply. However, I don’t want to do anything with the task itself, but with the file it represents and which is sent to the renderer. As far as I can see, the Task object does not have this property (I could only find TaskFrameList (int), TaskFrameString (str), TaskId (str), TaskRenderStatus (str), TaskSlaveMachineName (str), TaskStatus (str)). For example: for task 1 the file Mantra gets to render is \server\folder\file_0001.ifd. It is the path in bold I am interested in.
If you take a look at the PreRenderTasks function in \your\repository\plugins\Mantra\Mantra.py, you can see how we figure out which IFD file to render based on the current frame number:
#Get ifd filename.
ifdFile = self.GetPluginInfoEntryWithDefault( "SceneFile",self.GetDataFilename())
ifdFile = RepositoryUtils.CheckPathMapping( ifdFile )
ifdPaddingLength = FrameUtils.GetPaddingSizeFromFilename( ifdFile )
if( ifdPaddingLength > 0 ):
ifdFile = FrameUtils.SubstituteFrameNumber(ifdFile, StringUtils.ToZeroPaddedString(self.GetStartFrame(),ifdPaddingLength,False))
The job object in your post job script has a function to get the PluginInfo setting that we’re using above. So you could do something like this:
job = deadline_plugin.GetJob()
ifdFile = job.GetJobPluginInfoKeyValue( "SceneFile" )
if ifdFile == "":
ifdFile = job.JobAuxiliarySubmissionFileNames[0]
ifdFile = RepositoryUtils.CheckPathMapping( ifdFile )
ifdPaddingLength = FrameUtils.GetPaddingSizeFromFilename( ifdFile )
for frame in job.JobFramesList:
currIfdFile = FrameUtils.SubstituteFrameNumber(ifdFile, StringUtils.ToZeroPaddedString(frame,ifdPaddingLength,False))
deadline_plugin.LogInfo(currIfdFile)
os.remove(currIfdFile)
Note that this isn’t tested, and there could be syntax errors, but this should get you on the right track.
Cheers,
Ryan
Thank you, Ryan. That works perfectly