Having some trouble now setting some job data;
[code]import os
import re
from System.Text.RegularExpressions import *
from Deadline.Plugins import *
from Deadline.Jobs import *
from Deadline.Scripting import *
######################################################################
This is the function that Deadline calls to get an instance of the
main DeadlinePlugin class.
######################################################################
def GetDeadlinePlugin():
return CelActionPlugin()
def CleanupDeadlinePlugin( deadlinePlugin ):
deadlinePlugin.Cleanup()
######################################################################
This is the main DeadlinePlugin class for the CelAction plugin.
######################################################################
class CelActionPlugin(DeadlinePlugin):
def __init__( self ):
self.InitializeProcessCallback += self.InitializeProcess
self.RenderExecutableCallback += self.RenderExecutable
self.RenderArgumentCallback += self.RenderArgument
self.PostRenderTasksCallback += self.PostRenderTasks
def Cleanup(self):
for stdoutHandler in self.StdoutHandlers:
del stdoutHandler.HandleCallback
del self.InitializeProcessCallback
del self.RenderExecutableCallback
del self.RenderArgumentCallback
del self.PostRenderTasksCallback
def InitializeProcess(self):
# Set the plugin specific settings.
self.SingleFramesOnly = False
# Set the process specific settings.
self.StdoutHandling = True
self.PopupHandling = True
# Ignore 'celaction' Pop-up dialogs
self.AddPopupIgnorer(".*Rendering.*")
self.AddPopupIgnorer(".*Wait.*")
def RenderExecutable(self):
return self.GetConfigEntry("RenderExecutable")
def RenderArgument(self):
arguments = RepositoryUtils.CheckPathMapping(self.GetPluginInfoEntry( "Arguments" ).strip())
arguments = arguments.replace( "<STARTFRAME>", str(self.GetStartFrame()) )
arguments = arguments.replace( "<ENDFRAME>", str(self.GetEndFrame()) )
arguments = self.ReplacePaddedFrame( arguments, "<STARTFRAME%([0-9]+)>", self.GetStartFrame() )
arguments = self.ReplacePaddedFrame( arguments, "<ENDFRAME%([0-9]+)>", self.GetEndFrame() )
arguments = arguments.replace( "<QUOTE>", "\"" )
return arguments
def PostRenderTasks(self):
output_dir = self.GetJob().JobOutputDirectories[0]
output_name = self.GetJob().JobOutputFileNames[0]
padding = len(output_name.split('#')) - 1
head = output_name.split('#' * padding)[0]
tail = output_name.split('#' * padding)[1]
files = []
pattern = r'%s.*_[0-9]{%s}%s' % (head, padding, tail)
for f in os.listdir(output_dir):
if re.findall(pattern, f):
files.append(f.replace(tail, '')[:-padding])
for item in list(set(files)):
value = item + '#' * padding + tail
print value
self.GetJob().SetJobEnvironmentKeyValue('OutputFilename1', value)
def ReplacePaddedFrame( self, arguments, pattern, frame ):
frameRegex = Regex( pattern )
while True:
frameMatch = frameRegex.Match( arguments )
if frameMatch.Success:
paddingSize = int( frameMatch.Groups[ 1 ].Value )
if paddingSize > 0:
padding = StringUtils.ToZeroPaddedString( frame, paddingSize, False )
else:
padding = str(frame)
arguments = arguments.replace( frameMatch.Groups[ 0 ].Value, padding )
else:
break
return arguments
[/code]
Where “self.GetJob().SetJobEnvironmentKeyValue(‘OutputFilename1’, value)” doesn’t seem to work.
PS. I know the value would get overwritten, but just trying to get something written first.