Skip to content

Instantly share code, notes, and snippets.

@Kif11
Created October 28, 2016 08:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Kif11/b073246192925e252167fb1d508986ae to your computer and use it in GitHub Desktop.
Save Kif11/b073246192925e252167fb1d508986ae to your computer and use it in GitHub Desktop.
def get_maya_location():
"""
Return maya install location on Windows
Source: https://github.com/JukeboxPipeline/jukebox-core/blob/master/src/jukeboxcore/ostool.py
:returns: path to maya
:rtype: str
:raises: errors.SoftwareNotFoundError
"""
# The supported maya versions
MAYA_VERSIONS = ["2016", "2015"]
# Registry key on windows to access maya install path
MAYA_REG_KEY = "Software\\Autodesk\\Maya\\{mayaversion}\\Setup\\InstallPath"
import _winreg
# query winreg entry
# the last flag is needed, if we want to test with 32 bit python!
# Because Maya is an 64 bit key!
for ver in MAYA_VERSIONS:
try:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
MAYA_REG_KEY.format(mayaversion=ver), 0,
_winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)
value = _winreg.QueryValueEx(key, "MAYA_INSTALL_LOCATION")[0]
except WindowsError:
log.debug('Maya %s installation not found in registry!' % ver)
if not value:
raise Exception('Maya %s installation not found in registry!' % MAYA_VERSIONS)
return value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment