Created
October 28, 2016 08:33
-
-
Save Kif11/b073246192925e252167fb1d508986ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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