Here is a longer, in-memory version of the same function, as used in the actual SMTDFunctions code:
fn CallDeadlineCommandInMemory argument multiLine:false throwOnExitCode:false timeOut:3600 =
(
local resultMsg = ""
local exitCode = 0
try (
local p = dotnetobject "system.diagnostics.process"
p.StartInfo.FileName = SMTDPaths.DeadlineExec
p.StartInfo.Arguments = argument
p.StartInfo.RedirectStandardOutput = true
p.StartInfo.RedirectStandardError = true
p.StartInfo.UseShellExecute = false
p.StartInfo.CreateNoWindow = true
p.Start()
if multiLine then
local cmdOutput = p.StandardOutput.ReadToEnd() --multiple line output
else
local cmdOutput = p.StandardOutput.ReadLine() --single line output
p.WaitForExit(timeOut)
if p.ExitCode == 0 then
resultMsg = cmdOutput
else
(
-- Print stderr if any is captured
local cmdError = p.StandardError.ReadToEnd()
if cmdError != "" do print cmdError
print cmdOutput
exitCode = p.ExitCode
)
p.Dispose()
p = undefined
)catch(
local ex = getCurrentException()
print "The following error occurred while calling Deadline Command:"
print ex
)
if throwOnExitCode and exitCode != 0 then
throw ("Deadline command returned exit code: " + (exitCode as string))
resultMsg
)
theRepo = CallDeadlineCommandInMemory @"-getrepositorypath submission\3dsmax\Main"
if doesFileExist theRepo do theRepo += @"\SubmitMaxToDeadline_Functions.ms"
Note I did not write this. I think Mike Owen did, but I could be wrong.
Its benefit is that it does not write files to disk. Might be better for very long multi-line output like getting Slave info.
The Python code can be found in the various integrated submitters found in the respective Client folders, for example take a look at the Nuke or Houdini plugins…