1 '''
2 A class that allows for a dynamic allocation model for Nuke
3 '''
4
5
6
7
8
9 import sys
10 import qb.backend.pythonChildBackEnd
11
12
13 -class NukeBackEnd(qb.backend.pythonChildBackEnd.PythonChildBackEnd):
14 """
15 A backend for a jobtype that runs an instance of Nuke in a child process.
16
17 This will allow for the Nuke session to persist for the duration of the subjob.
18 """
19
21 """
22 Get the arguments to start the child python process.
23
24 @param port: the port on which the PyCmdDispatcher's backchannel instance is listening, usually
25 passed as a parameter to the child_bootstrapper.py script which starts up the pyCmdExecutor
26 inside child process started by the PyCmdDispatcher
27
28 @type port: C{int}
29
30 @return: Return a tuple of a list of args to start the python interpreter,
31 and a list of python commands to initialize the python working environment.
32
33 @rtype: C{tuple} C{([childArgs], [pyInitCmds])}
34 """
35
36 args = []
37 if sys.platform != 'win32':
38 args.extend(['/bin/tcsh', '-c'])
39
40 nukeArgs = self.job['package'].get('nukeArgs', '')
41 if not nukeArgs:
42 nukeArgs = ''
43
44 pyCmdLine = '"%s" %s -t "%s" --port %s --kind %s' % (self.pyExecutable, nukeArgs, self.childBootstrapper, port, self.job['kind'])
45
46 args.append(pyCmdLine)
47
48 pyInitCmds = [
49 'import nuke',
50 '''print "Nuke thread count: %s" % nuke.env['threads']''',
51 ]
52
53 return args, pyInitCmds
54