1
2
3
4
5
6
7 import os.path
8 import logging
9 import platform
10 import re
11
12 import qb.backend.utils as backendUtils
13
14
16 """
17 Some applications have different ways to start or be called, depending on either OS or
18 application version; this base class defines the default behavior.
19
20 Classes derived from this class can be used to define these differences on a case-by-case basis
21 at submission time, then the generic L{prepareCmd} method is called to setup the command to run.
22 """
24 self.logging = logging.getLogger('%s' % self.__class__.__name__)
25
27 '''
28 This method can be used to apply application version-specific or os-specific modifications
29 to the commandline necessary to run the job
30
31 @param job: the job object that has been passed to the instance in the back-end code
32 @type job: C{qb.Job}
33
34 @param cmd: the cmdline that the job will run
35 @type cmd: C{str}
36
37 @return: the cmd, modified for the appVersion or OS
38 '''
39 if platform.system() == 'Windows':
40
41 if backendUtils.pyVerAsFloat() < 2.7:
42 cmd = '"%s"' % cmd
43
44 return cmd
45
46
48 '''
49 On OS X, source the MayaEnv.sh, otherwise do nothing.
50 '''
52 cmd = super(MayaBatchCommandHandler, self).prepareCommand(job, cmd)
53
54 if platform.system() == 'Darwin':
55 if 'appToken' in job['package'] and 'appVersion' in job['package']:
56 appToken = job['package']['appToken']
57 appVersion = job['package']['appVersion']
58
59 mayaExe = backendUtils.translateAppPath(appToken, appVersion)
60 mayaExe = mayaExe.replace('"', '')
61 mayaDir = os.path.dirname(mayaExe)
62
63 cmd = '. "%s/MayaENV.sh" && %s' % (mayaDir, cmd)
64
65 return cmd
66
67
69 '''
70 On Windows, ensure that the slashes face the right way, and escape any ctrl-characters
71 '''
73 cmd = super(Cinema4DCommandHandler, self).prepareCommand(job, cmd)
74
75 if platform.system() == 'Windows':
76 cmd = cmd.replace('/', '\\')
77 cmd = 'start /b /wait "parentconsole" %s' % cmd
78
79 return cmd
80
81
83 '''
84 On
85 '''
87 cmd = super(SketchUpCommandHandler, self).prepareCommand(job, cmd)
88
89 if platform.system() == 'Windows':
90 cmd = cmd.replace('/', '\\')
91 cmd = '%s & echo return_code = %%ERRORLEVEL%%' % cmd
92
93 elif platform.system() == 'Darwin':
94 cmd = re.sub('__SKETCHUP__', 'open --wait-apps --fresh -a %s --args ' % job['package']['appToken'], cmd)
95
96 return cmd
97
111