Previous Topic (ScriptOverview) Up (Contents) Next Topic (ScriptingPostJobScripts)

Monitor Scripting

Monitor scripts fall into four categories: Submission Scripts, General Scripts, Job Scripts, and Slave Scripts. While Submission and General scripts don't differ in the context in which they are used, they fall under different menu items in the Monitor to keep them separate. Job and Slave scripts, on the other hand, have access to special functions that the other scripts don't.

Submission Scripts

Submission scripts are used to create custom submission dialogs in the Monitor's Submit menu. Creating your custom dialogs is quite simple, just follow the steps below. Once your script has been installed, simply restart the Monitor and you'll see your script in the Submit menu. Examples of submission scripts can be found in \\your\repository\scripts\Submission.

Installing Monitor Submission Scripts

  • Navigate to your \\your\repository\scripts\Submission folder.
  • Create a new folder to store your submission script. The name of the folder doesn't matter, but it will be consistent with the names of the files the folder will contain.
  • Open the new folder, and create an ini file using the new folder's name as the filename prefix. For example, if your folder name is MySubmissionScript, the ini file's name will be MySubmissionScript.ini. This ini file can contain the following information:
Label=My Submission Script
  • Create a Python file, again using the new folder's name as the filename prefix. If we're continuing off the example above, this file will be called MySubmissionScript.py.
  • As an option, you can create a 16x16 icon file that will appear next to the menu item, and place it in the new script folder. Again, use the new folder's name as the filename prefix.
  • Now if you restart the monitor, you should see a menu item in the Submit menu for your submission script, even if the script file is empty. Of course, clicking the menu item for you script will do nothing at this point.

Creating Monitor Submission Scripts

We follow a specific template when building the submission scripts that are included with Deadline. The Monitor submission script template is as follows.

  • Define your __main__ function: This is the main function called when you click on the script's menu item. It must be defined.
def __main__( *args ):
    ...
    do something
    ...
  • Build The Submission Dialog: You build your submission dialog in the __main__ function by getting a reference to a ScriptDialog object and adding controls to it. Each control's name must be unique, so that each control can be identified properly. You can also set the dialog's size, title, and a few other settings. See the User Interface Scripting section for a complete list of dialog functions and controls.
    • Define And Load Your Sticky Settings: Sticky settings are settings that persist after the dialog has been closed. They are defined by creating a string array which contains the names of the controls you wish to save settings for. After defining them, you can load them by calling the ScriptDialog function LoadSettings.
    • Show The Dialog: Show the dialog to the user using the ScriptDialog function ShowDialog.
  • Specify Your Functions: Specify any functions that may be used by the script. These could be helper functions, or event handlers that do stuff when values of controls are modified.

General Scripts

General scripts are used to perform any sort of custom action you want by selecting them from the Monitor's Scripts menu. Underneath the hood, there isn't anything different between General and Submission scripts except that you can limit which users can execute the script. We just added the extra menu item keep them separated.

Installing General Monitor Scripts

  • Navigate to your \\your\repository\scripts\General folder.
  • Create a new folder to store your script. The name of the folder doesn't matter, but it will be consistent with the names of the files the folder will contain.
  • Open the new folder, and create an ini file using the new folder's name as the filename prefix. For example, if your folder name is MyScript, the ini file's name will be MyScript.ini. This ini file can contain the following information:
Label=My Script
UserPermissions=AllUsers/PowerUsers/SuperUsers
  • Create a Python file, again using the new folder's name as the filename prefix. If we're continuing off the example above, this file will be called MyScript.py.
  • As an option, you can create a 16x16 icon file that will appear next to the menu item, and place it in the new script folder. Again, use the new folder's name as the filename prefix.
  • Now if you restart the monitor, you should see a menu item in the Scripts menu for your script, even if the script file is empty. Of course, clicking the menu item for you script will do nothing at this point.

Creating General Monitor Scripts

The general Monitor script template is as follows.

  • Define your __main__ function: This is the main function called when you click on the script's menu item. It must be defined.
def __main__( *args ):
    ...
    do something
    ...
  • Build the Script Dialog if applicable: If you plan on using a dialog for your script, you build your script dialog in the __main__ function by getting a reference to a ScriptDialog object and adding controls to it. Each control's name must be unique, so that each control can be identified properly. You can also set the dialog's size, title, and a few other settings. See the User Interface Scripting section for a complete list of dialog functions and controls.
    • Define And Load Your Sticky Settings: Sticky settings are settings that persist after the dialog has been closed. They are defined by creating a string array which contains the names of the controls you wish to save settings for. After defining them, you can load them by calling the ScriptDialog function LoadSettings.
    • Show The Dialog: Show the dialog to the user using the ScriptDialog function ShowDialog.
  • Specify Your Functions: Specify any functions that may be used by the script. These could be helper functions, or event handlers that do stuff when values of controls are modified.

Job Scripts

Job scripts are used to perform custom actions on one or more selected jobs in the job list. You can access these scripts by right-clicking on the job and selecting the Scripts menu. Job scripts have access to some additional functions so you can get information about the selected job(s).

Installing Monitor Job Scripts

  • Navigate to your \\your\repository\scripts\Jobs folder.
  • Create a new folder to store your script. The name of the folder doesn't matter, but it will be consistent with the names of the files the folder will contain.
  • Open the new folder, and create an ini file using the new folder's name as the filename prefix. For example, if your folder name is MyJobScript, the ini file's name will be MyJobScript.ini. This ini file can contain the following information:
Label=My Script
UserPermissions=AllUsers/JobUsers/PowerUsers/SuperUsers
Multiselect=True/False
  • Create a Python file, again using the new folder's name as the filename prefix. If we're continuing off the example above, this file will be called MyJobScript.py.
  • As an option, you can create a 16x16 icon file that will appear next to the menu item, and place it in the new script folder. Again, use the new folder's name as the filename prefix.
  • Now if you restart the monitor, you should see a menu item under the Scripts menu in the job's right-click menu for your job script, even if the script file is empty. Of course, clicking the menu item for you script will do nothing at this point.

Creating Monitor Job Scripts

The job Monitor script template is as follows.

  • Define your __main__ function: This is the main function called when you click on the script's menu item. It must be defined.
def __main__( *args ):
    ...
    do something
    ...
  • Build a Script Dialog if applicable: If you plan on using a dialog for your script, you build your script dialog in the __main__ function by getting a reference to a ScriptDialog object and adding controls to it. Each control's name must be unique, so that each control can be identified properly. You can also set the dialog's size, title, and a few other settings. See the User Interface Scripting section for a complete list of dialog functions and controls.
    • Define And Load Your Sticky Settings: Sticky settings are settings that persist after the dialog has been closed. They are defined by creating a string array which contains the names of the controls you wish to save settings for. After defining them, you can load them by calling the ScriptDialog function LoadSettings.
    • Show The Dialog: Show the dialog to the user using the ScriptDialog function ShowDialog.
  • Specify Your Functions: Specify any functions that may be used by the script. These could be helper functions, or event handlers that do stuff when values of controls are modified.

Job Utilities

These are specific to job scripts only. All functions are called by using JobUtils.function.

Function Description
string[] GetSelectedJobNames() Gets the list of selected job names.
string[] GetSelectedJobIds() Gets the list of selected job ids.
string GetDataFilename( int index ) Gets the scene file for the selected job at the specified index.
string GetFirstOutputFilename( int index ) Gets the first output filename for the selected job at the specified index.
int GetFirstFrame( int index ) Gets the first frame for the selected job at the specified index.
int GetLastFrame( int index ) Gets the last frame for the selected job at the specified index.
int GetPriority( int index ) Gets the priority for the selected job at the specified index.
string GetPool( int index ) Gets the pool for the selected job at the specified index.
string GetName( int index ) Gets the job name for the selected job at the specified index.
string GetJobId( int index ) Gets the job ID for the selected job at the specified index.
string GetDepartment( int index ) Gets the department for the selected job at the specified index.
string GetGroup( int index ) Gets the group for the selected job at the specified index.
object GetCurrentJobValue( int index, string property ) Gets the specified property for the selected job at the specified index, if it exists.
void SetCurrentJobValue( int index, string property, object value ) Sets the specified property for the selected job at the specified index, if it exists.
object GetCurrentPluginValue( int index, string property ) Gets the specified plug-in property for the selected job at the specified index, if it exists.
void SetCurrentPluginValue( int index, string property, object value ) Sets the specified plug-in property for the selected job at the specified index, if it exists.

Slave Scripts

Slave scripts are used to perform custom actions on one or more selected slaves in the slave list. You can access these scripts by right-clicking on the slave and selecting the Scripts menu. Slave scripts have access to some additional functions so you can get information about the selected slave(s).

Installing Monitor Slave Scripts

  • Navigate to your \\your\repository\scripts\Slaves folder.
  • Create a new folder to store your script. The name of the folder doesn't matter, but it will be consistent with the names of the files the folder will contain.
  • Open the new folder, and create an ini file using the new folder's name as the filename prefix. For example, if your folder name is MySlaveScript, the ini file's name will be MySlaveScript.ini. This ini file can contain the following information:
Label=My Script
UserPermissions=AllUsers/PowerUsers/SuperUsers
Multiselect=True/False
  • Create a Python file, again using the new folder's name as the filename prefix. If we're continuing off the example above, this file will be called MySlaveScript.py.
  • As an option, you can create a 16x16 icon file that will appear next to the menu item, and place it in the new script folder. Again, use the new folder's name as the filename prefix.
  • Now if you restart the monitor, you should see a menu item under the Scripts menu in the slave's right-click menu for your skave script, even if the script file is empty. Of course, clicking the menu item for you script will do nothing at this point.

Creating Monitor Slave Scripts

The slave Monitor script template is as follows.

  • Define your __main__ function: This is the main function called when you click on the script's menu item. It must be defined.
def __main__( *args ):
    ...
    do something
    ...
  • Build a Script Dialog if applicable: If you plan on using a dialog for your script, you build your script dialog in the __main__ function by getting a reference to a ScriptDialog object and adding controls to it. Each control's name must be unique, so that each control can be identified properly. You can also set the dialog's size, title, and a few other settings. See the User Interface Scripting section for a complete list of dialog functions and controls.
    • Define And Load Your Sticky Settings: Sticky settings are settings that persist after the dialog has been closed. They are defined by creating a string array which contains the names of the controls you wish to save settings for. After defining them, you can load them by calling the ScriptDialog function LoadSettings.
    • Show The Dialog: Show the dialog to the user using the ScriptDialog function ShowDialog.
  • Specify Your Functions: Specify any functions that may be used by the script. These could be helper functions, or event handlers that do stuff when values of controls are modified.

Slave Utilities

These are specific to slave scripts only. All functions are called by using SlaveUtils.function.

Function Description
string GetSelectedSlaveName( int index ) Gets the selected slave name at the specified index.
array GetSelectedSlaveNames() Gets the list of selected slave names.
array GetAssignedPools( string slaveName ) Gets the list of assigned pools for the specified slave.
array GetAssignedGroups( string slaveName ) Gets the list of assigned groups for the specified slave.
string GetDescription( string slaveName ) Gets the description for the specified slave.
string GetComment( string slaveName ) Gets the comment for the specified slave.
bool GetEnabled( string slaveName ) Gets if the specified slave is enabled.
object GetSlaveInfoValue( string slaveName, string property ) Gets a property value from the specified slave's SlaveInfo file.
object GetSlaveSettingValue( string slaveName, string property ) Gets a property value from the specified slave's settings.
void SendRemoteCommand( string slaveName, string command ) Sends the specified command to the specified slave and waits for it to respond.
void SendRemoteCommandNoWait( string slaveName, string command ) Sends the specified command to the specified slave and does not wait for it to respond.