Package qb :: Package backend :: Module appDefaultPaths
[hide private]
[frames] | no frames]

Source Code for Module qb.backend.appDefaultPaths

  1  ## ----------------------------------------------------------------------------- 
  2  ##    
  3  ##      Module defining expected default installation paths for some common 
  4  ##      3d-party applications 
  5  ## 
  6  ##      Copyright: Pipelinefx L.L.C.  
  7  ## 
  8  ## ----------------------------------------------------------------------------- 
  9   
 10  #====================================== 
 11  #  $Revision: #8 $ 
 12  #  $Change: 13718 $ 
 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          # expected to have 1 or 2 values; 5->(5), 5.5->(5,5), 6->(6), CC, CC 2014 
 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          # expected to have 1 or 2 values; R12->(12), R13.5->(13,5) 
 46          # Maxon installs the 32- and 64-bit exe's in the same dir on 64-bit OS's... 
 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          # Since R16 MAXON renders with Commandline instead of C4D executable 
 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          # expected to have 3 values; 6.4v2 -> (6,4,2) 
 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',                   # Maya XXXX, eg. 2012 
 82              '/Applications/Autodesk/maya%(v1)s.%(v2)s/Maya.app/Contents/bin/Render',            # Maya X.X, eg 8.5 
 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',                              # Maya XXXX, eg. 2012 
 90              'C:/Program Files/Autodesk/Maya%(v1)s.%(v2)s/bin/Render.exe',                       # Maya X.X, eg 8.5 
 91              'C:/Program Files/Autodesk/Maya%(v1)s Subscription Advantage Pack/bin/Render.exe',  # Subscription Packs are always year-based 
 92              # 32-bit 
 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',                    # XSI 7.0 
101              '/usr/Softimage/Softimage_%(v1)s/Application/bin/xsibatch',                         # Softimage 2011 
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   
128 -def buildAppPath(appToken, appVerTuple):
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 # build a dict with version components like {'v1': 6, 'v2': 5, 'v3':3} 157 # 158 # this will be used to evaluate the formatting tokens (%(v1)s, etc) in the 159 # appPathTemplate 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 # evaluate the path template against the version dictionary 171 # ensuring we have enough version components in the path template 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 # got a path with a different number of version components than the version 185 # dictionary, expected. eg. "CS5.5" vs "CS6" 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 # a couple of functions used by the AppVersionNotFoundError 202 # Exception class, but don't need to be class methods 203 #===========================================================
204 -def appName(appToken):
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
224 -def appVerAsStr(appVer):
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
236 -class AppVersionNotFoundError(QubeBackEndError):
237 - def __init__(self, appToken, appVer):
238 self.value = '%s: Unable to locate a local installation of %s %s' % (socket.gethostname(), appName(appToken), appVerAsStr(appVer))
239