Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
156 lines (118 sloc) 9.9 KB
from System.Collections.Specialized import *
from System.IO import *
from System.Text import *
from Deadline.Scripting import *
from DeadlineUI.Controls.Scripting.DeadlineScriptDialog import DeadlineScriptDialog
########################################################################
## Globals
########################################################################
scriptDialog = None
settings = None
########################################################################
## Main Function Called By Deadline
########################################################################
def __main__( *args ):
global scriptDialog
global settings
scriptDialog = DeadlineScriptDialog()
scriptDialog.SetTitle( "Submit chef-client run To Deadline" )
scriptDialog.SetIcon( scriptDialog.GetIcon( 'Chef' ) )
scriptDialog.AddGrid()
scriptDialog.AddControlToGrid( "Separator1", "SeparatorControl", "Job Description", 0, 0, colSpan=3 )
scriptDialog.AddControlToGrid( "NameLabel", "LabelControl", "Job Name", 1, 0, "The name of your job. This is optional, and if left blank, it will default to 'Untitled'.", False )
scriptDialog.AddControlToGrid( "NameBox", "TextControl", "Untitled", 1, 1, colSpan=2)
scriptDialog.AddControlToGrid( "CommentLabel", "LabelControl", "Comment", 2, 0, "A simple description of your job. This is optional and can be left blank.", False )
scriptDialog.AddControlToGrid( "CommentBox", "TextControl", "", 2, 1, colSpan=2 )
scriptDialog.AddControlToGrid( "DepartmentLabel", "LabelControl", "Department", 3, 0, "The department you belong to. This is optional and can be left blank.", False )
scriptDialog.AddControlToGrid( "DepartmentBox", "TextControl", "", 3, 1, colSpan=2 )
scriptDialog.EndGrid()
scriptDialog.AddGrid()
scriptDialog.AddControlToGrid( "Separator2", "SeparatorControl", "Job Options", 0, 0, colSpan=3 )
scriptDialog.AddControlToGrid( "PoolLabel", "LabelControl", "Pool", 1, 0, "The pool that your job will be submitted to.", False )
scriptDialog.AddControlToGrid( "PoolBox", "PoolComboControl", "none", 1, 1 )
scriptDialog.AddControlToGrid( "SecondaryPoolLabel", "LabelControl", "Secondary Pool", 2, 0, "The secondary pool lets you specify a Pool to use if the primary Pool does not have any available Slaves.", False )
scriptDialog.AddControlToGrid( "SecondaryPoolBox", "SecondaryPoolComboControl", "", 2, 1 )
scriptDialog.AddControlToGrid( "GroupLabel", "LabelControl", "Group", 3, 0, "The group that your job will be submitted to.", False )
scriptDialog.AddControlToGrid( "GroupBox", "GroupComboControl", "none", 3, 1 )
scriptDialog.AddControlToGrid( "PriorityLabel", "LabelControl", "Priority", 4, 0, "A job can have a numeric priority ranging from 0 to 100, where 0 is the lowest priority and 100 is the highest priority.", False )
scriptDialog.AddRangeControlToGrid( "PriorityBox", "RangeControl", RepositoryUtils.GetMaximumPriority() / 2, 0, RepositoryUtils.GetMaximumPriority(), 0, 1, 4, 1 )
scriptDialog.AddControlToGrid( "TaskTimeoutLabel", "LabelControl", "Task Timeout", 5, 0, "The number of minutes a slave has to render a task for this job before it requeues it. Specify 0 for no limit.", False )
scriptDialog.AddRangeControlToGrid( "TaskTimeoutBox", "RangeControl", 0, 0, 1000000, 0, 1, 5, 1 )
scriptDialog.AddSelectionControlToGrid( "AutoTimeoutBox", "CheckBoxControl", False, "Enable Auto Task Timeout", 5, 2, "If the Auto Task Timeout is properly configured in the Repository Options, then enabling this will allow a task timeout to be automatically calculated based on the render times of previous frames for the job. " )
scriptDialog.AddControlToGrid( "ConcurrentTasksLabel", "LabelControl", "Concurrent Tasks", 6, 0, "The number of tasks that can render concurrently on a single slave. This is useful if the rendering application only uses one thread to render and your slaves have multiple CPUs.", False )
scriptDialog.AddRangeControlToGrid( "ConcurrentTasksBox", "RangeControl", 1, 1, 16, 0, 1, 6, 1 )
scriptDialog.AddSelectionControlToGrid( "LimitConcurrentTasksBox", "CheckBoxControl", True, "Limit Tasks To Slave's Task Limit", 6, 2, "If you limit the tasks to a slave's task limit, then by default, the slave won't dequeue more tasks then it has CPUs. This task limit can be overridden for individual slaves by an administrator." )
scriptDialog.AddControlToGrid( "MachineLimitLabel", "LabelControl", "Machine Limit", 7, 0, "", False )
scriptDialog.AddRangeControlToGrid( "MachineLimitBox", "RangeControl", 0, 0, 1000000, 0, 1, 7, 1 )
scriptDialog.AddSelectionControlToGrid( "IsBlacklistBox", "CheckBoxControl", False, "Machine List Is A Blacklist", 7, 2, "" )
scriptDialog.AddControlToGrid( "MachineListLabel", "LabelControl", "Machine List", 8, 0, "Use the Machine Limit to specify the maximum number of machines that can render your job at one time. Specify 0 for no limit.", False )
scriptDialog.AddControlToGrid( "MachineListBox", "MachineListControl", "", 8, 1, colSpan=2 )
scriptDialog.AddControlToGrid( "LimitGroupLabel", "LabelControl", "Limits", 9, 0, "The Limits that your job requires.", False )
scriptDialog.AddControlToGrid( "LimitGroupBox", "LimitGroupControl", "", 9, 1, colSpan=2 )
scriptDialog.AddControlToGrid( "DependencyLabel", "LabelControl", "Dependencies", 10, 0, "Specify existing jobs that this job will be dependent on. This job will not start until the specified dependencies finish rendering. ", False )
scriptDialog.AddControlToGrid( "DependencyBox", "DependencyControl", "", 10, 1, colSpan=2 )
scriptDialog.AddControlToGrid( "OnJobCompleteLabel", "LabelControl", "On Job Complete", 11, 0, "If desired, you can automatically archive or delete the job when it completes. ", False )
scriptDialog.AddControlToGrid( "OnJobCompleteBox", "OnJobCompleteControl", "Nothing", 11, 1 )
scriptDialog.AddSelectionControlToGrid( "SubmitSuspendedBox", "CheckBoxControl", False, "Submit Job As Suspended", 11, 2, "If enabled, the job will submit in the suspended state. This is useful if you don't want the job to start rendering right away. Just resume it from the Monitor when you want it to render. " )
scriptDialog.EndGrid()
scriptDialog.AddGrid()
scriptDialog.AddControlToGrid( "Separator3", "SeparatorControl", "Chef Options", 0, 0, colSpan=4)
scriptDialog.AddControlToGrid("LogLevelLabel", "LabelControl", "Log Level", 1, 0, "The level of logging Chef will provide.", False)
scriptDialog.AddComboControlToGrid( "LogLevelComboBox", "ComboControl", "warn", ["debug", "info", "warn", "error", "fatal"], 1, 1)
scriptDialog.EndGrid()
scriptDialog.AddGrid()
scriptDialog.AddHorizontalSpacerToGrid( "HSpacer1", 0, 0 )
submitButton = scriptDialog.AddControlToGrid( "SubmitButton", "ButtonControl", "Submit", 0, 1, expand=False )
submitButton.ValueModified.connect(SubmitButtonPressed)
closeButton = scriptDialog.AddControlToGrid( "CloseButton", "ButtonControl", "Close", 0, 2, expand=False )
closeButton.ValueModified.connect(scriptDialog.closeEvent)
scriptDialog.EndGrid()
settings = ( "DepartmentBox","CategoryBox","PoolBox","SecondaryPoolBox","GroupBox","PriorityBox","IsBlacklistBox","MachineListBox","LimitGroupBox","LogLevelComboBox" )
scriptDialog.LoadSettings( GetSettingsFilename(), settings )
scriptDialog.EnabledStickySaving( settings, GetSettingsFilename() )
scriptDialog.ShowDialog( False )
def GetSettingsFilename():
return Path.Combine( ClientUtils.GetUsersSettingsDirectory(), "ChefSettings.ini" )
def SubmitButtonPressed( *args ):
global scriptDialog
jobInfoFilename = Path.Combine( ClientUtils.GetDeadlineTempPath(), "chef_job_info.job" )
try:
writer = StreamWriter( jobInfoFilename, False, Encoding.Unicode )
except Exception as e:
scriptDialog.ShowMessageBox("error: " + str(e) , "")
writer.WriteLine( "Plugin=Chef" )
writer.WriteLine( "Name=%s" % scriptDialog.GetValue( "NameBox" ) )
writer.WriteLine( "Comment=%s" % scriptDialog.GetValue( "CommentBox" ) )
writer.WriteLine( "Department=%s" % scriptDialog.GetValue( "DepartmentBox" ) )
writer.WriteLine( "Pool=%s" % scriptDialog.GetValue( "PoolBox" ) )
writer.WriteLine( "SecondaryPool=%s" % scriptDialog.GetValue( "SecondaryPoolBox" ) )
writer.WriteLine( "Group=%s" % scriptDialog.GetValue( "GroupBox" ) )
writer.WriteLine( "Priority=%s" % scriptDialog.GetValue( "PriorityBox" ) )
writer.WriteLine( "TaskTimeoutMinutes=%s" % scriptDialog.GetValue( "TaskTimeoutBox" ) )
writer.WriteLine( "LimitGroups=%s" % scriptDialog.GetValue( "LimitGroupBox" ) )
writer.WriteLine( "JobDependencies=%s" % scriptDialog.GetValue( "DependencyBox" ) )
writer.WriteLine( "OnJobComplete=%s" % scriptDialog.GetValue( "OnJobCompleteBox" ) )
#writer.WriteLine( "Frames=0" )
#writer.WriteLine( "ChunkSize=1" )
writer.WriteLine( "MaintenanceJob=true" )
writer.WriteLine( "MaintenanceJobStartFrame=0" )
writer.WriteLine( "MaintenanceJobEndFrame=0" )
if( bool(scriptDialog.GetValue( "IsBlacklistBox" )) ):
writer.WriteLine( "Blacklist=%s" % scriptDialog.GetValue( "MachineListBox" ) )
else:
writer.WriteLine( "Whitelist=%s" % scriptDialog.GetValue( "MachineListBox" ) )
if( bool(scriptDialog.GetValue( "SubmitSuspendedBox" )) ):
writer.WriteLine( "InitialStatus=Suspended" )
writer.Close()
# Create plugin info file.
pluginInfoFilename = Path.Combine( ClientUtils.GetDeadlineTempPath(), "chef_plugin_info.job" )
writer = StreamWriter( pluginInfoFilename, False, Encoding.Unicode )
writer.WriteLine("LogLevel=%s" % scriptDialog.GetValue("LogLevelComboBox") )
writer.Close()
# Setup the command line arguments.
arguments = StringCollection()
arguments.Add( jobInfoFilename )
arguments.Add( pluginInfoFilename )
# Now submit the job.
results = ClientUtils.ExecuteCommandAndGetOutput( arguments )
scriptDialog.ShowMessageBox( results, "Submission Results" )
You can’t perform that action at this time.