示例#1
0
def getMayaAppDir(versioned=False):
    """
    Determine the Maya application directory, first by checking MAYA_APP_DIR, then by
    trying OS-specific defaults.
    
    if versioned is True, the current Maya version including '-x64' suffix, if applicable, will be appended.
    """ 
    appDir = os.environ.get('MAYA_APP_DIR',None)
    if appDir is None :
        if os.name == 'nt':
            appDir = os.environ.get('USERPROFILE',os.environ.get('HOME',None))
            if appDir is None:
                return

            # Vista or newer... version() returns "6.x.x"
            if int(platform.version().split('.')[0]) > 5:
                appDir = os.path.join( appDir, 'Documents')
            else:
                appDir = os.path.join( appDir, 'My Documents')
        else:
            appDir = os.environ.get('HOME',None)
            if appDir is None:
                return

        if platform.system() == 'Darwin':
            appDir = os.path.join( appDir, 'Library/Preferences/Autodesk/maya' )
        else:
            appDir = os.path.join( appDir, 'maya' )
    
    if versioned and appDir:
        appDir = os.path.join(appDir, versions.installName())
    
    return appDir
示例#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
示例#3
0
def getMayaAppDir(versioned=False):
    """
    Determine the Maya application directory, first by checking MAYA_APP_DIR, then by
    trying OS-specific defaults.
    
    if versioned is True, the current Maya version including '-x64' suffix, if applicable, will be appended.
    """
    appDir = os.environ.get('MAYA_APP_DIR', None)
    if appDir is None:
        if os.name == 'nt':
            appDir = os.environ.get('USERPROFILE',
                                    os.environ.get('HOME', None))
            if appDir is None:
                return

            # Vista or newer... version() returns "6.x.x"
            if int(platform.version().split('.')[0]) > 5:
                appDir = os.path.join(appDir, 'Documents')
            else:
                appDir = os.path.join(appDir, 'My Documents')
        else:
            appDir = os.environ.get('HOME', None)
            if appDir is None:
                return

        if platform.system() == 'Darwin':
            appDir = os.path.join(appDir, 'Library/Preferences/Autodesk/maya')
        else:
            appDir = os.path.join(appDir, 'maya')

    if versioned and appDir:
        appDir = os.path.join(appDir, versions.installName())

    return appDir
示例#4
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
示例#5
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