AWS Thinkbox Discussion Forums

Working on Event Plugins

It can difficult to iterate testing Event Plugins, as they may require a job error or a new job submission to test. It’s possible to add a __main__() function to a script and call the event functions there. I’ve attached an example of what that looks like in the DevelopingPlugin.zip.

It doesn’t do anything, but if you’re getting tired of manually completing the same job over and over to test your OnJobFinished event this can help out.

The important bit is the __main__():

# To ease troubleshooting, let's add a __main__ method so we can call our event without having to submit and complete jobs

# Run the __main__ function you have to use deadlinecommand -executescript DevelopingEvent.py
# __main__ will not be run when the event is run through the event system.
def __main__():   
# Our event functions (OnJobSubmitted and OnJobFinished) take self and a job object as arguemnts  
# First we need to get a job object. Right click a job in the Monitor -> Scripts -> Copy Job ID   
    test_job_id = "6621468c28182aaeb0741a3f" # replace this with what you've gotten
    test_job = RepositoryUtils.GetJob(test_job_id, True)
    print(f"The test job is named {test_job.JobName}") # Prove that we haven't used the wrong Job ID before testing
    my_event = DevelopingEvent()
    # Call our event
    my_event.OnJobFinished(test_job)

DevelopingEvent.zip (1.3 KB)

4 Likes
Privacy | Site terms | Cookie preferences