Pre Job Script Help

Hi!
Could you please help me with pre job script? I need to suspend all uncompleted (active or queued or pending) jobs in defined pool (let’s call it “tempPool” for example). I think it’s pretty easy, but i’m novice in python scripting, so if you don’t mind could you paste code here? With all “import” lines. If i would have a script that works, it will be easy for me to manage with scripts further. Thank you!

i wrote something like that, but i don’t quite sure that it’s right:

from Deadline.Scripting import *

def _main_():
	allJobs = GetJobs()
	for i in allJobs:
		if (allJobs[i].JobPool == "mov_final"):
			if (allJobs[i].JobStatus == "Pending" or allJobs[i].JobStatus == "Active"):
				allJobs[i].JobStatus = "Suspended"

I threw this script together, which seems to do the job:

from Deadline.Scripting import *

def __main__( *args ):
	jobIds = RepositoryUtils.GetJobIds()
	for jobId in jobIds:
		try:
			job = RepositoryUtils.GetJob( jobId, False )
			if job.JobPool == "global":
				if job.JobStatus == "Pending" or job.JobStatus == "Active":
					results = ClientUtils.ExecuteCommandAndGetOutput( ("SuspendJob", job.JobId) )
					ClientUtils.LogText( results )
		except:
			pass

Cheers,

  • Ryan

This works great for me! Now i understand it more clearly (have just wrote post job script also), thank you!