How to switch Job's Status from Completed to Active and back to Completed

Sometimes we need Draft Event to re-generate a Quicktime for the job that was already completed.
The work around was to right-click the job and from right-click menu to choose “Requeue Job” command.
Then before the job gets picked up by a slave we right-click the job again and choose “Complete Job” command.

Trying to automate this two-steps process with Python:

selectedJobs = MonitorUtils.GetSelectedJobs() for job in selectedJobs: RepositoryUtils.RequeueJob(job) RepositoryUtils.CompleteJob(job)

This approach requeues the Job (its status is switched to “Active”).
But the Job’s Status is not set to “Completed” with RepositoryUtils.CompleteJob(job) command.

How to achieve this?

I just tested this using the attached script file in Deadline 7.2.1.10 and Deadline 8.0.0.47 and both work just fine. You can double-check it’s working via the Console Panel (print messages) and also by right-click the job -> View Job History…

RequeueCompleteJob.py.zip (436 Bytes)

[code]"""
RequeueCompleteJob.py - Requeue and then Complete a job to force the Draft event plugin to execute
“”"

from Deadline.Scripting import *

########################################################################

Main Function Called By Deadline

########################################################################
def main():
selectedJobs = MonitorUtils.GetSelectedJobs()
for job in selectedJobs:
print “job state: %s” % job.JobStatus
RepositoryUtils.RequeueJob(job)
print “job state: %s” % job.JobStatus
RepositoryUtils.CompleteJob(job)
print “job state: %s” % job.JobStatus[/code]

Thanks Mike,
I’ve tested it with Deadline 6.2. By some reason the Job gets re-queued but not Completed.

Instead of switching the Job’s Status from Completed-to-Requeued-back-to-Completed I wounder if it would be possible to simply trigger the Draft Event?

Simple right-click menu Python script would look something like this:

from Deadline.Scripting import * def __main__(): selectedJobs = MonitorUtils.GetSelectedJobs() for job in selectedJobs: draftObject.OnJobFinished(job)

Since I have the Job object I can probably pass it along to Draft Event?

Ah, I couldn’t find a release note specifically on this issue, so I guess an upgrade would be the easiest option here?

I can’t think of a way to trick or force an event plugin to trigger in Deadline 6.2.

The only other thing I can think of if an upgrade is out of the question is to spawn a process in your py script which executes:

DeadlineCommand.exe -CompleteJob [jobId]

I just checked and that function works ok in 6 for you.

This should do it.

[code]"""
RequeueCompleteJob.py - Requeue and then Complete a job to force the Draft event plugin to execute
“”"
from System.IO import *
from System.Diagnostics import *

from Deadline.Scripting import *

########################################################################

Main Function Called By Deadline

########################################################################
def main():
selectedJobs = MonitorUtils.GetSelectedJobs()
for job in selectedJobs:

	RepositoryUtils.RequeueJob(job)
	
	deadlineCommand = Path.Combine( ClientUtils.GetBinDirectory(), "DeadlineCommand.exe" )
	arguments = "-CompleteJob " + job.JobId
	process = ProcessUtils.SpawnProcess( deadlineCommand, arguments, ClientUtils.GetBinDirectory(), ProcessWindowStyle.Hidden, True )
	ProcessUtils.WaitForExit( process, -1 )[/code]