Hi,
I want to create a monitor script to to do the above but I am having a hard time sorting through the scripting documentation. I have a fairly good handle on maxscript but I seem to be missing how to do a few key things.
I would think the approach would be something like:
get an array of the currently selected job ids using JobUtils.GetSelectedJobIds()
go through the array and add up each job’s total render time - not sure what to use here, though there is a GetJobTaskTotalTime command for deadlinecommand?
Display or output this value - is there a way to display the value in deadline (maybe with a dialog box?) or write to a file (again, I can’t find any i/o stuff except for in deadlinecommand)
Also, is there a way to display output from a command as in the max listener?
This seems like it should be a pretty simple script to write but I am lost. Any advice or a push in the right direction would be greatly appreciated!
Thanks,
Brad
Hey Brad,
Here’s what you can do:
-
Use JobUtils.GetSelectedJobIds() to get the list of selected jobs.
-
Loop through that list, build up the command for GetJobTaskTotalTime, and use ScriptUtils.ExecuteCommandAndGetOutput() to get the output returned. This function is explained here:
software.primefocusworld.com/sof … _Utilities
For an example on how to build up the StringCollection arguments, check out \your\repository\scripts\submission\BlenderSubmission\BlenderSubmission.py for an example.
- For saving the data to a file or displaying it in a dialog, you can also refer to the BlenderSubmission.py file above. We use .NET’s I/O classes to create the job info and plugin info files, so that will be a good reference. We also create a submission dialog for blender, so that’s a good reference as well. The user interface documentation can be found here:
software.primefocusworld.com/sof … _Scripting
Finally, you can use ScriptUtils.LogText() to output debug info to the Monitor Log file. You can find the log from the Monitor by selecting Help -> Explore Log Folder.
Hope this helps!
Thanks Ryan, that’s great!
I’ll let you know how it goes.
Brad
Hi Ryan, I’m having trouble with the ScriptUtils.ExecuteCommandAndGetOutput command.
I am using it in the following context:
ScriptUtils.ExecuteCommandAndGetOutput( ‘GetJobTaskTotalTime’,‘000_080_999_08d1bead’ )
where the ‘000_080_999_08d1bead’ is a job ID.
I get the following error:
type object ‘ScriptUtils’ has no attribute ‘ExecuteCommandAndGetOutput’ (System.MissingMemberException) (System Exception)
Any ideas?
Thanks,
Brad
Hey Brad,
Could you post your script? It could be the usage of the function, or a missing import statement, that could be causing the problem.
Also, which version of Deadline are you using?
Thanks!
Hi Ryan, we’re on version 3.0 here.
The script I’m using to bug test is as follows:
from System.IO import *
from Deadline.Scripting import *
########################################################################
## Globals
########################################################################
scriptDialog = None
settings = None
########################################################################
## Main Function Called By Deadline
########################################################################
def __main__():
jobTime = ScriptUtils.ExecuteCommandAndGetOutput( 'GetJobTaskTotalTime','000_080_999_08d1bead' )
I wasn’t sure if that is the correct way to attach the output to a variable so have tried
ScriptUtils.ExecuteCommand( ‘GetJobIds’ )
and that comes up with the same error.
On the up-side the file IO stuff you pointed me towards is working well!
Thanks,
Brad
Hi Brad,
Unfortunately, the ScriptUtils.ExecuteCommandAndGetOutput function wasn’t introduced until Deadline 3.1, which would explain the error you’re getting. Something like the following should work as an alternative though:
from System.Diagnostics import *
startInfo = ProcessStartInfo("c:\path\to\deadlinecommand.exe", "GetJobTaskTotalTime 000_080_999_08d1bead" )
startInfo.RedirectStandardOutput = True
process = Process.Start( startInfo )
jobTime = p.StandardOutput.ReadToEnd()
process.WaitForExit()
This is untested, but should give you the right idea. Note that I’m using the .NET Process class:
msdn.microsoft.com/en-us/library … cess(VS.80.aspx
Cheers,
Hi Ryan, thanks for the help. I didn’t have any luck with that but we will be upgrading to v4 of deadline in the next week or two so I will wait till then before I have another crack.
Cheers,
Brad