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?
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?
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?
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.
#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"')
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!