Python, how to?

##------------------------------------------------------------
## StopVraySpawner2012.py
##------------------------------------------------------------
	
from System.IO import *
from Deadline.Scripting import *
from Deadline.Slaves import *

def __main__():
	slaveNames = SlaveUtils.GetSelectedSlaveNames()
	mySlaveSettings = SlaveSettings()
	description = mySlaveSettings.SlaveDescription
	mySlaveSettings.SlaveDescription = "Vray Spawner is stopped"
	RepositoryUtils.SaveSlaveSettings()
	
	for slaveName in slaveNames:   
		SlaveUtils.SendRemoteCommandNoWait( slaveName, "taskkill /im vrayspawner2012.exe /f /t" )
		SlaveUtils.SendRemoteCommandNoWait( slaveName, "deadlineslave")

I’m trying to create a small script that kills the VraySpawner, and at the same time adds a description to the slave. The kill part works fine, but I can’t make the description part to work. I got no prior python experience, so that might been the main problem :slight_smile:

I get an error on “RepositoryUtils.SaveSlaveSettings()” it wants 1 argument but I can’t seem to figure out which one, and I can’t find any info about this, and should the descrption code part be inside the for loop?
Can anybody help?

SaveSlaveSettings takes the SlaveSettings object as the parameter. Note though that in your current code, you’re creating a new instance of the SaveSettings object, meaning that if you commit it, you’ll be overwriting other settings like the pools and groups the slave is assigned to. You can use the RepositoryUtils.GetSlaveSettings function to get the current settings for the slave. You code would probably end up looking something like this:

##------------------------------------------------------------
## StopVraySpawner2012.py
##------------------------------------------------------------
   
from System.IO import *
from Deadline.Scripting import *
from Deadline.Slaves import *

def __main__():
   slaveNames = SlaveUtils.GetSelectedSlaveNames()
   
   for slaveName in slaveNames:   
      SlaveUtils.SendRemoteCommandNoWait( slaveName, "taskkill /im vrayspawner2012.exe /f /t" )
      SlaveUtils.SendRemoteCommandNoWait( slaveName, "deadlineslave")
      
       mySlaveSettings = RepositoryUtils.GetSlaveSettings( slaveName )
       mySlaveSettings.SlaveDescription = "Vray Spawner is stopped"
       RepositoryUtils.SaveSlaveSettings( mySlaveSettings )

Cheers,

  • Ryan

Perfect, thanks :slight_smile:
Now I have to learn python :neutral_face:

Could you update this for the latest Deadline and Vray spawner in max 2021?