Job Script issues

Sorry, I feel like I’ve been spamming this board these last few days… but I have another question

I have a job script that uses the os module, imported by adding a network path to a CPy 2.4 installation’s Lib folder to the repository’s Python Search Paths. This path is fully visible on the network, and the script runs fine up until the script tries to run a command using os.system(…), at which point Deadline throws this error:

[code]Could not run script because an error occurred:

Python Error: ‘module’ object has no attribute ‘system’
(System.MissingMemberException)
(System.Exception)[/code]

Is this a problem related to importing the module from a network path? Or does Deadline’s internal interpreter forbid system-level command access? Do I need to use a .NET method to execute the command?

Thanks in advance.

-Nathan

Hey Nathan,

You could use one of the SpawnProcess helper functions:
franticfilms.com/software/su … _Utilities

So if you had:

from os import *
...
os.system( "application.exe arg1 arg2" )

You could replace it with something like:

from System.Diagnostics import *
...
ProcessUtils.SpawnProcess( "appliation.exe", "arg1 arg2" )

Cheers,

  • Ryan

Here’s what I’m hoping to achieve:

If you run Nuke in terminal mode from a command shell, it returns the Python interpreter prompt running inside of Nuke. Will SpawnProcess behave similarly? Or will it spawn the process in a completely new environment? Would ShellExecute keep the terminal running inside Deadline’s interpreter?

Also, is there a documented or known reason os.system() is nonfunctional in Deadline?

You could probably use the Process .NET class to start a process and pipe python statements to it. That would require some .NET learning though:
msdn.microsoft.com/en-us/library … ocess.aspx
csharp-station.com/HowTo/ProcessStart.aspx
allegro.cc/forums/thread/596335

os.system() should be working though… not sure why it wouldn’t be

This just gets weirder and weirder…

I’m running a different script now that avoids the os module altogether, and now I’m getting this error:

Python Error: NotImplementedError
(System.NotImplementedException)
(System.Exception)

I’ve run the script in a separate CPython 2.4 interpreter prompt, and it all works fine… I know it’s not a very specific or enlightening error, but do you have any idea why this might be happening?

EDIT: Could this be related to IronPython’s lack of support for C/C libraries?

Thanks

Can you post the script you’re trying to run? Like you said, the error message isn’t telling us much, so the script might put the error in better context.

Cheers,

  • Ryan

[code]from Deadline.Scripting import *
import sgConnect

def main():
#Get job variables from Deadline
deadlineJobName = JobUtils.GetSelectedJobNames()[0]
deadlineJobId = JobUtils.GetSelectedJobIds()[0]
deadlineOutPath = JobUtils.GetCurrentJobValue(0, “OutputDirectories”)[0].replace("\" , “/”)
deadlineOutName = JobUtils.GetCurrentJobValue(0, “OutputFileNames”)[0]
deadlineFrames = JobUtils.GetCurrentJobValue(0, “FramesList”)

#Connect to Shotgun
sg = sgConnect.connect()

#Build job-specific query variables
jobNumber = None
jobPath = None
if deadlineOutPath.startswith('W:/'):
	jobPath = deadlineOutPath.strip('W:/')
	jobNumber = jobPath[0:5]
elif deadlineOutPath.startswith('O:/'):
	pass

#Get Shotgun ID of the job
queryFilters = [['name', 'contains', jobNumber], ]
jobQueryResult = sg.find('Project', queryFilters)
sgJobId = jobQueryResult[0]['id']

renderJobData = {
	'project':{'type':'Project','id':sgJobId},
	'sg_system_task_type':'Render',
	'sg_status_list':'fin',
	'content':deadlineJobName,
	'task_assignees':[{'type':'User','id':47}, ],
	}

result = sg.create('Task', renderJobData)[/code]

I think the problem is just that the Shotgun API module being loaded through my sgConnect module probably isn’t compatible with IronPython’s CPython implementation.

In the meantime, I’ve been trying to hack together an ugly workaround script that dumps job variables to a temp file, calls a separate Python 2.6 install, and passes it a .py script which then parses the temp file, but even that doesn’t work correctly. I’ve tried os.system(), which apparently is still M.I.A, and also SpawnProcess. I’ve included an example below… am I messing this up somehow?

ProcessUtils.SpawnProcess("C:\\Python26\\python.exe", '"O:\\Scripts and Extensions\\Shotgun\\Py2Shot\\Py2Shot_v.01.py"')

Thanks

Maybe having the two sets of quotes around the script argument is causing problems. Try this instead:

ProcessUtils.SpawnProcess("C:\\Python26\\python.exe", "O:\\Scripts and Extensions\\Shotgun\\Py2Shot\\Py2Shot_v.01.py")

Hmm… perhaps you’re right. I’ll give that a shot when I get off my current task. I was thinking in terms of Python syntax for the Windows command line, trying to capture the double quotes in a string to pass, like one would normally have to do with a process command that contains spaces.

Well, it turns out my original syntax was correct (quotes inside quotes). I had another error that was getting lost in the shuffle (chock that up to a long day…) but the process is starting fine now. Thanks again for your help!