SlaveUtils doesn't exist?

Hi,
SlaveUtils command Like SlaveUtils.SendRemoteCommand(str(computer_name()), ForceStopSlave) return me SlaveUtils is not defined. I Import Deadline repo into my script … In doc and in a previous post the given command was the same …
Any Idear ?

Are you importing deadline .scripting?

from Deadline.Scripting import *

Yes, tolding me that Scripting module doesn’t exist, but other script use it ^^’’
I try deadlinecommand computername ForceStopSlave ~ but not forcing the rendering job to stop :confused:

In what context are you using this script? Do you run it from monitor or?

No, This is for a Standalone Python Script. I add sys.path.append(repo deadline api path)
I use Deadline.DeadlineConnect without problem
And the deadlinecommand RemoteControl computername ForceStopSlave dont return me error exept the rendering doesn’t stop :sweat_smile:

Ok. I’ve never used it like that. Have you looked into Standalone Python API documentation and/or Deadline Standalone Python Reference if it provides what you need?

I use it already to get the Slave Status. Infact the ForceStopSlave disable and stop the slave if he’s in idle state. In Deadline Monitor, when I go in Disable i can check Stop Slave and kill slave if necessary. Is that 2 Different commands ?
The StandAlonePython API is just here to get information from the deadline server, you can not really send command to control slaves.
I try to kill the slave and sandbox process throught CMD but as expected it often goes to stalled the slave… ^^ The strange things is that if I go on the local machine bin path, run a CMD into it and then run deadlinecommand.exe RemoteControl <Computer Name> ForceStopSlave ~ The slave forcestop. The same on python script wont work … strange I continue my search :stuck_out_tongue:

Thanks for all the help that’s cool

Could it be that the machine name needs to be in array format? (At this point I’m just guessing)
like:

[machine name] → [machine1, machine2,…, machineX]

edit: Scratch that, it’s not needed.

Some info from @eamsler

Well, this works.
(Copied from “SoftimageToDeadlineFunctions.py”)

import os
import subprocess

def GetDeadlineCommand():
    deadlineBin = ""
    try:
        deadlineBin = os.environ['DEADLINE_PATH']
    except KeyError:
        #if the error is a key error it means that DEADLINE_PATH is not set. however Deadline command may be in the PATH or on OSX it could be in the file /Users/Shared/Thinkbox/DEADLINE_PATH
        pass
        
    # On OSX, we look for the DEADLINE_PATH file if the environment variable does not exist.
    if deadlineBin == "" and  os.path.exists( "/Users/Shared/Thinkbox/DEADLINE_PATH" ):
        with open( "/Users/Shared/Thinkbox/DEADLINE_PATH" ) as f:
            deadlineBin = f.read().strip()

    deadlineCommand = os.path.join(deadlineBin, "deadlinecommand")
    
    return deadlineCommand

def CallDeadlineCommand( arguments, background=True, readStdout=True ):
    deadlineCommand = GetDeadlineCommand()

    startupinfo = None
    creationflags = 0
    if os.name == 'nt':
        if background:
            # Python 2.6 has subprocess.STARTF_USESHOWWINDOW, and Python 2.7 has subprocess._subprocess.STARTF_USESHOWWINDOW, so check for both.
            if hasattr( subprocess, '_subprocess' ) and hasattr( subprocess._subprocess, 'STARTF_USESHOWWINDOW' ):
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
            elif hasattr( subprocess, 'STARTF_USESHOWWINDOW' ):
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        else:
            # still show top-level windows, but don't show a console window
            CREATE_NO_WINDOW = 0x08000000   #MSDN process creation flag
            creationflags = CREATE_NO_WINDOW
        
    arguments.insert( 0, deadlineCommand)
    
    stdoutPipe = None
    if readStdout:
        stdoutPipe=subprocess.PIPE
        
    # Specifying PIPE for all handles to workaround a Python bug on Windows. The unused handles are then closed immediatley afterwards.
    proc = subprocess.Popen(arguments, stdin=subprocess.PIPE, stdout=stdoutPipe, stderr=subprocess.PIPE, startupinfo=startupinfo, creationflags=creationflags )
    proc.stdin.close()
    proc.stderr.close()

    output = ""
    if readStdout:
        output = proc.stdout.read()
    return output

print CallDeadlineCommand(["GetFarmStatistics"]) 

So for shutting down slave the command would be

[" RemoteControl", "computername", "ForceStopSlave"]