1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 import os.path
16 import platform
17 import logging
18 import socket
19
20 from qb.backend import QubeBackEndError
21
22
23 installPath = {
24 'AE': {
25
26 'Darwin': [
27 '/Applications/Adobe After Effects %(v1)s/aerender',
28 '/Applications/Adobe After Effects %(v1)s %(v2)s/aerender',
29 '/Applications/Adobe After Effects CS%(v1)s/aerender',
30 '/Applications/Adobe After Effects CS%(v1)s.%(v2)s/aerender'
31 ],
32 'Windows': [
33 'C:/Program Files/Adobe/Adobe After Effects %(v1)s/Support Files/aerender.exe',
34 'C:/Program Files/Adobe/Adobe After Effects %(v1)s %(v2)s/Support Files/aerender.exe',
35 'C:/Program Files/Adobe/Adobe After Effects CS%(v1)s/Support Files/aerender.exe',
36 'C:/Program Files/Adobe/Adobe After Effects CS%(v1)s.%(v2)s/Support Files/aerender.exe',
37
38 'C:/Program Files (x86)/Adobe/Adobe After Effects %(v1)s/Support Files/aerender.exe',
39 'C:/Program Files (x86)/Adobe/Adobe After Effects %(v1)s %(v2)s/Support Files/aerender.exe',
40 'C:/Program Files (x86)/Adobe/Adobe After Effects CS%(v1)s/Support Files/aerender.exe',
41 'C:/Program Files (x86)/Adobe/Adobe After Effects CS%(v1)s.%(v2)s/Support Files/aerender.exe',
42 ],
43 },
44 'C4D': {
45
46
47 'Darwin': [
48 '/Applications/MAXON/CINEMA 4D R%(v1)s/CINEMA 4D.app/Contents/MacOS/CINEMA 4D',
49 '/Applications/MAXON/CINEMA 4D R%(v1)s.%(v2)s/CINEMA 4D.app/Contents/MacOS/CINEMA 4D',
50 ],
51 'Windows': [
52 'C:\\Program Files\\MAXON\\CINEMA 4D R%(v1)s\\CINEMA 4D 64 Bit.exe',
53 'C:\\Program Files\\MAXON\\CINEMA 4D R%(v1)s.%(v2)s\\CINEMA 4D 64 Bit.exe',
54
55 'C:\\Program Files\\MAXON\\CINEMA 4D R%(v1)s\\CINEMA 4D.exe',
56 'C:\\Program Files\\MAXON\\CINEMA 4D R%(v1)s.%(v2)s\\CINEMA 4D.exe',
57
58 'C:\\Program Files (x86)\\MAXON\\CINEMA 4D R%(v1)s\\CINEMA 4D.exe',
59 'C:\\Program Files (x86)\\MAXON\\CINEMA 4D R%(v1)s.%(v2)s\\CINEMA 4D.exe',
60 ],
61 },
62 'C4DCL': {
63
64 'Darwin': [
65 '/Applications/MAXON/CINEMA 4D R%(v1)s/Commandline.app/Contents/MacOS/Commandline',
66 '/Applications/MAXON/CINEMA 4D R%(v1)s.%(v2)s/Commandline.app/Contents/MacOS/Commandline',
67 ],
68 'Windows': [
69 'C:\\Program Files\\MAXON\\CINEMA 4D R%(v1)s\\Commandline.exe',
70 'C:\\Program Files\\MAXON\\CINEMA 4D R%(v1)s.%(v2)s\\Commandline.exe',
71 ],
72 },
73 'NUKE': {
74
75 'Darwin': ['/Applications/Nuke%(v1)s.%(v2)sv%(v3)s/Nuke%(v1)s.%(v2)sv%(v3)s.app/Contents/MacOS/Nuke%(v1)s.%(v2)sv%(v3)s'],
76 'Linux': ['/usr/local/Nuke%(v1)s.%(v2)sv%(v3)s/Nuke%(v1)s.%(v2)s'],
77 'Windows': ['C:/Program Files/Nuke%(v1)s.%(v2)sv%(v3)s/Nuke%(v1)s.%(v2)s.exe'],
78 },
79 'MAYA': {
80 'Darwin': [
81 '/Applications/Autodesk/maya%(v1)s/Maya.app/Contents/bin/Render',
82 '/Applications/Autodesk/maya%(v1)s.%(v2)s/Maya.app/Contents/bin/Render',
83 ],
84 'Linux': [
85 '/usr/autodesk/maya%(v1)s-x64/bin/Render',
86 '/usr/autodesk/maya%(v1)s/bin/Render',
87 ],
88 'Windows': [
89 'C:/Program Files/Autodesk/Maya%(v1)s/bin/Render.exe',
90 'C:/Program Files/Autodesk/Maya%(v1)s.%(v2)s/bin/Render.exe',
91 'C:/Program Files/Autodesk/Maya%(v1)s Subscription Advantage Pack/bin/Render.exe',
92
93 'C:/Program Files (x86)/Autodesk/Maya%(v1)s/bin/Render.exe',
94 'C:/Program Files (x86)/Autodesk/Maya%(v1)s.%(v2)s/bin/Render.exe',
95 'C:/Program Files (x86)/Autodesk/Maya%(v1)s Subscription Advantage Pack/bin/Render.exe',
96 ],
97 },
98 'XSI': {
99 'Linux': [
100 '/usr/Softimage/XSI_%(v1)s.%(v2)s_x64/Application/bin/xsibatch',
101 '/usr/Softimage/Softimage_%(v1)s/Application/bin/xsibatch',
102 '/usr/Softimage/XSI_%(v1)s.%(v2)s/Application/bin/xsibatch',
103 ],
104 'Windows': [
105 'C:/Softimage/XSI_%(v1)s.%(v2)s_x64/Application/bin/XSIBatch.bat',
106 'C:/Softimage/Softimage_%(v1)s_x64/Application/bin/XSIBatch.bat',
107
108 'C:/Program Files/Autodesk/Softimage %(v1)s/Application/bin/XSIBatch.bat',
109 'C:/Program Files/Autodesk/Softimage %(v1)s Subscription Advantage Pack/Application/bin/XSIBatch.bat',
110
111 'C:/Program Files (x86)/Autodesk/Softimage %(v1)s/Application/bin/XSIBatch.bat',
112 'C:/Program Files (x86)/Autodesk/Softimage %(v1)s Subscription Advantage Pack/Application/bin/XSIBatch.bat',
113 ],
114 },
115 'SKETCHUP': {
116 'Windows': [
117 'C:/Program Files/SketchUp/SketchUp %(v1)s/SketchUp.exe',
118 'C:/Program Files (x86)/SketchUp/SketchUp %(v1)s/SketchUp.exe'
119 ],
120 'Darwin': [
121 '/Applications/SketchUp %(v1)s/SketchUp.app/Contents/MacOS/SketchUp'
122 ]
123
124 },
125 }
126
127
129 '''
130 Determine a good guess at where an app will be for a particular OS and word-size
131
132 @param appToken: An all-caps short name for the application, must be a key in the L{installPath} dictionary.
133 @type appToken: C{str}
134
135 @param appVerTuple: A tuple containing the application version components, the last value may be
136 an optional architecture; B{x86} or B{x64}
137
138 @type appVerTuple: C{tuple}
139
140 @raise AppVersionNotFoundError: Raised when the requested version of the application is not
141 found in any of the paths specified in the L{installPath} dictionary.
142
143 @return: Return the path to the specified version and app on the local worker
144 @rtype: C{str}
145 '''
146 appPath = ''
147
148 if appToken in installPath:
149 plat = platform.system()
150
151 if isinstance(appVerTuple[-1], str) and appVerTuple[-1] in ['x86', 'x64']:
152 plat = '%s-%s' % (plat, appVerTuple[-1])
153 appVerTuple = appVerTuple[:-1]
154
155
156
157
158
159
160
161 appVer = {}
162 for i in range(len(appVerTuple)):
163 appVer['v%s' % str(i+1)] = appVerTuple[i]
164
165 invalidPaths = []
166 if plat in installPath[appToken]:
167 for pth in installPath[appToken][plat]:
168 try:
169
170
171
172
173 if '%%(v%i)s' % len(appVer) in pth:
174 appPath = pth % appVer
175 if os.path.isfile(appPath):
176 break
177 else:
178 invalidPaths.append(appPath)
179 appPath = ''
180 else:
181 continue
182
183 except KeyError:
184
185
186 continue
187 else:
188 logging.error('%s is not a recognized application token, the only recognized tokens are: %s' % (appToken, installPath.keys().__repr__()))
189 raise QubeBackEndError, 'unrecognized application token'
190
191 if appPath == '':
192 logging.error('Looked for application in:\n%s' % '\n'.join(['\t%s' % x for x in invalidPaths]))
193 raise AppVersionNotFoundError, (appToken, appVerTuple)
194
195 appPath = '"%s"' % appPath
196
197 return appPath
198
199
200
201
202
203
205 '''
206 Return a human-readable name for an appToken, one of the keys in L{installPath}
207
208 @param appToken: the all-caps application name token that's present in the submitted command; eg: "AE", "C4D", "MAYA"
209 @type appToken: C{str}
210
211 @return: a human-readable application name
212 @rtype: C{str}
213 '''
214 appNameMap = {
215 'AE': 'After Effects',
216 'C4D': 'Cinema 4D',
217 'XSI': 'XSI'
218 }
219
220 appName = appNameMap.get(appToken, appToken.capitalize())
221
222 return appName
223
225 '''
226 Return an arbitrary-length tuple of integers as a dotted string
227
228 @param appVer: A tuple of integers
229 @type appVer: {tuple}
230
231 @return: a version number as a dotted string
232 @rtype: C{str}
233 '''
234 return '.'.join([str(x) for x in appVer])
235
238 self.value = '%s: Unable to locate a local installation of %s %s' % (socket.gethostname(), appName(appToken), appVerAsStr(appVer))
239