Hey, so first off I’m super new to Deadline and not the most experienced programmer aswell.
I want to use a custom event to add a python script as a post job script to each render job submitted. I’ve tried several different attempts but to no avail. There is just nothing happening, not even some Error message in the console.
This is my code so far:
from Deadline.Events import DeadlineEventListener
from Deadline.Jobs import Job
import sys
def GetDeadlineEventListener():
return SubmitEventTest()
def CleanupDeadlineEventListener(eventListener):
eventListener.Cleanup()
class SubmitEventTest(DeadlineEventListener):
def __init__(self):
if sys.version_info.major == 3:
super().__init__()
self.OnJobSubmittedCallback += self.OnJobSubmitted
def Cleanup(self):
del self.OnJobSubmittedCallback
## This is called when a job is submitted.
def OnJobSubmitted(self, job):
postJobScriptPath = "PathToTheScript\DeadlineRepository10\custom\scripts\Jobs\MyScript.py"
job.AddPostJobScript(postJobScriptPath)
job.SaveJob()
I also created a .param file just to ensure that the event was enabled:
[State]
Type=Enum
Items=Global Enabled;Opt-In;Disabled
Category=Options
CategoryOrder=0
Index=0
Label=State
Default=Global Enabled
Description=How this event plugin should respond to events.
If someone could nudge me in the right direction of what I’m missing, I’d be super happy - thanks
This older post is still relevant to what you want to accomplish:
Can probably add a self.LogInfo(“Job saved with post-job script.”) so it will be logged.
There are way better coders/pipeline devs on this forum (I’m a sysadmin) , so hopefully one of them will chime in.
thank you very much, that solved my problem already!
I’ve seen the post before too, but I think I had some other bugs in my code because it still didn’t work then.
Just for archival purposes here is the working code
from Deadline.Events import DeadlineEventListener
from Deadline.Scripting import RepositoryUtils
import sys
def GetDeadlineEventListener():
return SubmitEventTest()
def CleanupDeadlineEventListener(eventListener):
eventListener.Cleanup()
class SubmitEventTest(DeadlineEventListener):
def __init__(self):
if sys.version_info.major == 3:
super().__init__()
self.OnJobSubmittedCallback += self.OnJobSubmitted
def Cleanup(self):
del self.OnJobSubmittedCallback
## This is called when a job is submitted.
def OnJobSubmitted(self, job):
postJobScriptPath = "PathToTheScript\DeadlineRepository10\custom\scripts\Jobs\MyScript.py"
RepositoryUtils.SetPostJobScript(job, postJobScriptPath)
RepositoryUtils.SaveJob(job)
self.LogInfo("Job saved with post-job script.")