Example #1
0
def getMayaLocation(version=None):
    """ Remember to pass the FULL version (with extension if any) to this function! """
    try:
        loc = os.path.realpath( os.environ['MAYA_LOCATION'] )
    except:
        loc = os.path.dirname( os.path.dirname( sys.executable ) )
    # get the path of a different maya version than current
    if version:
        # note that a recursive loop between getMayaLocation / getMayaVersion
        # is avoided because getMayaVersion always calls getMayaLocation with
        # version == None
        actual_long_version = versions.installName()
        actual_short_version = versions.shortName()
        if version != actual_long_version:
            short_version = versions.parseVersionStr(version, extension=False)
            if version == short_version :
                try_version = actual_long_version.replace(actual_short_version, short_version)
            else :
                try_version = version
            try_loc = loc.replace( actual_long_version, try_version )
            if os.path.exists(try_loc) :
                loc = try_loc
            else :
                _logger.warn("No Maya found for version %s" % version )
                loc = None

    return loc
Example #2
0
def getMayaLocation(version=None):
    """ Remember to pass the FULL version (with extension if any) to this function! """
    try:
        loc = os.path.realpath(os.environ['MAYA_LOCATION'])
    except:
        loc = os.path.dirname(os.path.dirname(sys.executable))
    # get the path of a different maya version than current
    if version:
        # note that a recursive loop between getMayaLocation / getMayaVersion
        # is avoided because getMayaVersion always calls getMayaLocation with
        # version == None
        actual_long_version = versions.installName()
        actual_short_version = versions.shortName()
        if version != actual_long_version:
            short_version = versions.parseVersionStr(version, extension=False)
            if version == short_version:
                try_version = actual_long_version.replace(
                    actual_short_version, short_version)
            else:
                try_version = version
            try_loc = loc.replace(actual_long_version, try_version)
            if os.path.exists(try_loc):
                loc = try_loc
            else:
                _logger.warn("No Maya found for version %s" % version)
                loc = None

    return loc
Example #3
0
def getMayaLocation(version=None):
    """
    Get the location of Maya (defined as the directory above /bin)

    Uses the $MAYA_LOCATION environment variable and sys.executable path.

    If version is passed, will attempt to find a matching Maya location.  If the
    version found by the methods above does not match the requested version, 
    this function uses a simple find/replace heuristic to modify the path and test
    if the desired version exists.  If no matching version is found, returns None

    Remember to pass the FULL version (with extension if any) to this function! """
    try:
        loc = os.path.realpath(os.environ['MAYA_LOCATION'])
    except:
        loc = os.path.dirname(os.path.dirname(sys.executable))
    # get the path of a different maya version than current
    if version:
        # note that a recursive loop between getMayaLocation / getMayaVersion
        # is avoided because getMayaVersion always calls getMayaLocation with
        # version == None
        actual_long_version = versions.installName()
        actual_short_version = versions.shortName()
        if version != actual_long_version:
            short_version = versions.parseVersionStr(version, extension=False)
            if version == short_version:
                try_version = actual_long_version.replace(
                    actual_short_version, short_version)
            else:
                try_version = version
            try_loc = loc.replace(actual_long_version, try_version)
            if os.path.exists(try_loc):
                loc = try_loc
            else:
                _logger.warn("No Maya found for version %s" % version)
                loc = None

    return loc
def getMayaLocation(version=None):
    """
    Get the location of Maya (defined as the directory above /bin)

    Uses the $MAYA_LOCATION environment variable and sys.executable path.

    If version is passed, will attempt to find a matching Maya location.  If the
    version found by the methods above does not match the requested version, 
    this function uses a simple find/replace heuristic to modify the path and test
    if the desired version exists.  If no matching version is found, returns None

    Remember to pass the FULL version (with extension if any) to this function! """
    try:
        loc = os.path.realpath( os.environ['MAYA_LOCATION'] )
    except:
        loc = os.path.dirname( os.path.dirname( sys.executable ) )
    # get the path of a different maya version than current
    if version:
        # note that a recursive loop between getMayaLocation / getMayaVersion
        # is avoided because getMayaVersion always calls getMayaLocation with
        # version == None
        actual_long_version = versions.installName()
        actual_short_version = versions.shortName()
        if version != actual_long_version:
            short_version = versions.parseVersionStr(version, extension=False)
            if version == short_version :
                try_version = actual_long_version.replace(actual_short_version, short_version)
            else :
                try_version = version
            try_loc = loc.replace( actual_long_version, try_version )
            if os.path.exists(try_loc) :
                loc = try_loc
            else :
                _logger.warn("No Maya found for version %s" % version )
                loc = None

    return loc