AWS Thinkbox Discussion Forums

Forcing a failure from python in a bat file

Simple setup…

I have a bat file which calls python to run a script with some parameters. This is being run by a commandscriptjob in deadline.

I want to be able to force that deadline task to fail if something fails a test in the python file fails… I thought just setting the stdout to -1 would cause Deadline to pick this up? But the task still lists as being completed successfully?

If your process itself (I guess in your case, the batch script) returns a non-zero exit code, Deadline will fail the job.

If for whatever reason it’s not possible for you to return a code other than 0, you will likely have to add some hooks in the //deadlineRepo/plugins/CommandScript/CommandScript.py script to catch it from stdout.

A good example of how this is implemented is in the plugins/MayaBatch folder. That’s the only plugin I’ve really modified around here, and it was pretty smooth sailing.

Also, side note, if you end up modifying this or any other plugin, I’d suggest placing it in the deadlineRepo/custom/plugins folder

You should be able to add your own errors to fail on in the InitalizeProcess() like:

def InitializeProcess(self):
    # Set the plugin specific settings.
    self.SingleFramesOnly = False

    # Set the process specific settings.
    self.StdoutHandling = True
    self.PopupHandling = True

    #-kw- fail on errors.
    self.AddStdoutHandlerCallback(".*ERROR:.*").HandleCallback += self.HandleError
    self.AddStdoutHandlerCallback(".*Error:.*").HandleCallback += self.HandleError
    self.AddStdoutHandlerCallback(".*Error :.*").HandleCallback += self.HandleError


    # fail on windows cant find error.:
    self.AddStdoutHandlerCallback(".*No such file or directory.*").HandleCallback += self.HandleError

If you print to std out , “ERROR”, it should catch and mark the task as fail.

Thanks will give this a try!

Privacy | Site terms | Cookie preferences