Exemple #1
0
def initializeNewMayaRelease():
    """This method should be called once a new maya release is encountered. It will
	initialize and update the database as well as possible, and give instructions 
	on what to do next.
	
	:note: Will not run if any user setup is performed as we need a clean maya 
	without any plugins loaded.
	:raise EnvironmentError: if the current maya version has already been initialized
	or if the user setup was executed"""
    if int(os.environ.get('MRV_STANDALONE_AUTOLOAD_PLUGINS', 0)) or \
     int(os.environ.get('MRV_STANDALONE_RUN_USER_SETUP', 0)):
        raise EnvironmentError(
            "Cannot operate if custom user setup was performed")
    # END check environments

    import env
    import mdb

    nodeshf = mdb.nodeHierarchyFile()
    app_version = env.appVersion()[0]
    if nodeshf.isfile():
        raise EnvironmentError(
            "Maya version %g already initialized as hierarchy file at %s does already exist"
            % (app_version, nodeshf))
    # END assure we are not already initialized

    # UPDATE MFN DB FILES
    #####################
    # Get all MFn function sets and put in their new versions as well as files
    mdb.writeMfnDBCacheFiles()

    # UPDATE NODE HIERARCHY FILE
    ############################
    # create all node types, one by one, and query their hierarchy relationship.
    # From that info, generate a dagtree which is written to the hierarchy file.
    # NOTE: for now we just copy the old one
    dagTree, typeToMFnList = mdb.generateNodeHierarchy()
    dagTree.to_hierarchy_file('_root_', mdb.nodeHierarchyFile())

    # UPDATE MFN ASSOCIATIONS
    #########################
    fp = open(mdb.cacheFilePath('nodeTypeToMfnCls', 'map'), 'wb')
    mla = reduce(max, (len(t[0]) for t in typeToMFnList))
    mlb = reduce(max, (len(t[1]) for t in typeToMFnList))

    psf = PipeSeparatedFile(fp)
    psf.beginWriting((mla, mlb))
    for token in typeToMFnList:
        psf.writeTokens(token)
    # END for each line to write
    fp.close()

    # PROVIDE INFO	TO THE USER
    ############################
    print >> sys.stderr, "1. git status might reveals new MFnFunction sets as untracked files - check the new methods and possibly define aliases (or delete them wiht 'x')"
    print >> sys.stderr, "2. Check the 'whats new' part of the maya docs for important API changes and possibly incorporate them into the code"
    print >> sys.stderr, "3. run 'tmrv %g' and fix possibly breaking tests or the code being tested" % app_version
    print >> sys.stderr, "4. run 'tmrvr' to assure all maya versions are still working - ideally on all platforms."
    print >> sys.stderr, "5. run the UI tests and assure that they don't fail"
    print >> sys.stderr, "6. Commit and push your changes - you are done"
Exemple #2
0
def initializeNewMayaRelease( ):
    """This method should be called once a new maya release is encountered. It will
    initialize and update the database as well as possible, and give instructions 
    on what to do next.
    
    :note: Will not run if any user setup is performed as we need a clean maya 
    without any plugins loaded.
    :raise EnvironmentError: if the current maya version has already been initialized
    or if the user setup was executed"""
    if int(os.environ.get('MRV_STANDALONE_AUTOLOAD_PLUGINS', 0)) or \
        int(os.environ.get('MRV_STANDALONE_RUN_USER_SETUP', 0)):
        raise EnvironmentError("Cannot operate if custom user setup was performed")
    # END check environments
    
    import env
    import mdb

    nodeshf = mdb.nodeHierarchyFile()
    app_version = env.appVersion()[0]
    if nodeshf.isfile():
        raise EnvironmentError("Maya version %g already initialized as hierarchy file at %s does already exist" % (app_version, nodeshf))
    # END assure we are not already initialized
    
    # UPDATE MFN DB FILES
    #####################
    # Get all MFn function sets and put in their new versions as well as files
    mdb.writeMfnDBCacheFiles()
    
    # UPDATE NODE HIERARCHY FILE
    ############################
    # create all node types, one by one, and query their hierarchy relationship.
    # From that info, generate a dagtree which is written to the hierarchy file.
    # NOTE: for now we just copy the old one
    dagTree, typeToMFnList = mdb.generateNodeHierarchy()
    dagTree.to_hierarchy_file('_root_', mdb.nodeHierarchyFile())
    
    # UPDATE MFN ASSOCIATIONS
    #########################
    fp = open(mdb.cacheFilePath('nodeTypeToMfnCls', 'map'), 'wb')
    mla = reduce(max, (len(t[0]) for t in typeToMFnList))
    mlb = reduce(max, (len(t[1]) for t in typeToMFnList))
    
    psf = PipeSeparatedFile(fp)
    psf.beginWriting((mla, mlb))
    for token in typeToMFnList:
        psf.writeTokens(token)
    # END for each line to write
    fp.close()
    
    
    # PROVIDE INFO  TO THE USER
    ############################
    print >> sys.stderr, "1. git status might reveals new MFnFunction sets as untracked files - check the new methods and possibly define aliases (or delete them wiht 'x')"
    print >> sys.stderr, "2. Check the 'whats new' part of the maya docs for important API changes and possibly incorporate them into the code"
    print >> sys.stderr, "3. run 'tmrv %g' and fix possibly breaking tests or the code being tested" % app_version
    print >> sys.stderr, "4. run 'tmrvr' to assure all maya versions are still working - ideally on all platforms."
    print >> sys.stderr, "5. run the UI tests and assure that they don't fail"
    print >> sys.stderr, "6. Commit and push your changes - you are done"
Exemple #3
0
	def writeToFile( self, filepath ):
		"""Write our database contents to the given file"""
		klist = self.keys()
		klist.sort()

		fobj = open( filepath, 'w' )
		pf = PipeSeparatedFile( fobj )
		pf.beginWriting( ( 4,40,20,40 ) )

		for key in klist:							# write entries
			e = self[ key ]
			pf.writeTokens( ( e.flag, key,e.rvalfunc, e.newname ) )
		# end for each key

		fobj.close()
Exemple #4
0
    def writeToFile(self, filepath):
        """Write our database contents to the given file"""
        klist = self.keys()
        klist.sort()

        fobj = open(filepath, 'w')
        pf = PipeSeparatedFile(fobj)
        pf.beginWriting((4, 40, 20, 40))

        for key in klist:  # write entries
            e = self[key]
            pf.writeTokens((e.flag, key, e.rvalfunc, e.newname))
        # end for each key

        fobj.close()