Ejemplo n.º 1
0
def install(offline=None, unistall=False):

    mayaAppDir = mel.eval('getenv MAYA_APP_DIR')
    scriptsDir = "%s%sscripts" % (mayaAppDir, os.sep)
    userSetupFile = scriptsDir + os.sep + "userSetup.py"
    newUserSetup = ""

    try:
        with open(userSetupFile, 'r'):

            input = open(userSetupFile, 'r')
            lines = input.readlines()

            # clear old aTool codes, if there is any
            write = True
            for n, line in enumerate(lines):
                if line.find("# start aTools") == 0:
                    write = False

                if write: newUserSetup += line

                if line.find("# end aTools") == 0:
                    write = True

    except IOError:
        newUserSetup = ""

    aToolCode = "# start aTools\n\nfrom maya import cmds\nif not cmds.about(batch=True):\n\n    # launch aTools_Animation_Bar\n    cmds.evalDeferred(\"from aTools.animTools.animBar import animBarUI; animBarUI.show('launch')\", lowestPriority=True)\n\n# end aTools"

    if not unistall: newUserSetup += aToolCode

    # write user setup file
    output = open(userSetupFile, 'w')
    output.write(newUserSetup)
    output.close()

    if offline:

        offlineFilePath = offline[0]
        createMelFile = offline[1]
        offlineFolder = os.sep.join(offlineFilePath.split(os.sep)[:-1])
        fileModTime = os.path.getmtime(offlineFilePath)

        aToolsMod.saveInfoWithUser("userPrefs", "offlinePath",
                                   [offlineFolder, fileModTime])
        if createMelFile == True:
            createOfflineMelFile(offlineFolder, scriptsDir)

    #open tool
    if not unistall:
        from aTools.animTools.animBar import animBarUI
        reload(animBarUI)
        animBarUI.show()
Ejemplo n.º 2
0
def install(offline=None, unistall=False):    
       
    mayaAppDir      = mel.eval('getenv MAYA_APP_DIR')
    scriptsDir      = "%s%sscripts"%(mayaAppDir, os.sep)
    userSetupFile   = scriptsDir + os.sep + "userSetup.py"  
    newUserSetup    = ""  
    
    
    try:
        with open(userSetupFile, 'r'):
            
            input = open(userSetupFile, 'r')
            lines = input.readlines()  
            
            # clear old aTool codes, if there is any
            write = True
            for n, line in enumerate(lines):        
                if line.find("# start aTools") == 0:
                    write = False
                    
                if write: newUserSetup += line
                    
                if line.find("# end aTools") == 0:
                    write = True
                    
    except IOError:
        newUserSetup    = ""       
    
    aToolCode  = "# start aTools\n\nfrom maya import cmds\nif not cmds.about(batch=True):\n\n    # launch aTools_Animation_Bar\n    cmds.evalDeferred(\"from aTools.animTools.animBar import animBarUI; animBarUI.show('launch')\", lowestPriority=True)\n\n# end aTools"    
        
    if not unistall: newUserSetup    += aToolCode
    
    # write user setup file
    output = open(userSetupFile, 'w')
    output.write(newUserSetup)
    output.close()
    
    
    if offline:        
        
        offlineFilePath = offline[0]
        createMelFile   = offline[1]
        offlineFolder   = os.sep.join(offlineFilePath.split(os.sep)[:-1])
        fileModTime     = os.path.getmtime(offlineFilePath)
        
        aToolsMod.saveInfoWithUser("userPrefs", "offlinePath", [offlineFolder, fileModTime]) 
        if createMelFile == True: createOfflineMelFile(offlineFolder, scriptsDir)
    
    
    #open tool
    if not unistall:
        from aTools.animTools.animBar import animBarUI; reload(animBarUI)
        animBarUI.show()
Ejemplo n.º 3
0
def refreshAToolsDef():
    from aTools.animTools.animBar import animBarUI;     reload(animBarUI)
    animBarUI.show('refresh')
Ejemplo n.º 4
0
def refreshAToolsDef():
    from aTools.animTools.animBar import animBarUI;     reload(animBarUI)
    animBarUI.show('refresh')
Ejemplo n.º 5
0
def aToolsOfflineInstall(offlineFilePath):

    mayaAppDir      = mel.eval('getenv MAYA_APP_DIR')    
    aToolsPath      = mayaAppDir + os.sep + 'scripts'
    aToolsFolder    = aToolsPath + os.sep + 'aTools' + os.sep
    tmpZipFile      = '%s%stmp.zip'%(aToolsPath, os.sep)
    offlineFileUrl  = r'file:///%s'%offlineFilePath
        
    if os.path.isfile(tmpZipFile):     os.remove(tmpZipFile)   
    if os.path.isdir(aToolsFolder): shutil.rmtree(aToolsFolder)      
    
    output = download(offlineFileUrl, tmpZipFile)    
    
    zfobj = zipfile.ZipFile(tmpZipFile)
    for name in zfobj.namelist():
        uncompressed = zfobj.read(name)
    
        filename  = formatPath('%s%s%s'%(aToolsPath, os.sep, name))        
        d         = os.path.dirname(filename)
        
        if not os.path.exists(d): os.makedirs(d)
        if filename.endswith(os.sep): continue
        
        output = open(filename,'wb')
        output.write(uncompressed)
        output.close()
        
    zfobj.close()
    if os.path.isfile(tmpZipFile):     os.remove(tmpZipFile)
    from aTools import setup; reload(setup); setup.install([offlineFilePath, False]) 
    cmds.evalDeferred(\"from aTools.animTools.animBar import animBarUI; reload(animBarUI); animBarUI.show(\'refresh\')\")