def getVersionComment(assetVersion, originalFileName): # Gets the comment of that version from the .nodeInfo file. filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) checkInDest = amu.getCheckinDest(filePath) return amu.getVersionComment(checkInDest, assetVersion)
def getCheckoutDest(coPath): # Returns the checkout destination path - inside the user's directory. nodeInfo = ConfigParser() nodeInfo.read(os.path.join(coPath, ".nodeInfo")) version = nodeInfo.get("Versioning", "latestversion") return os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(coPath))+"_"+os.path.basename(coPath)+"_"+("%03d" % int(version)))
def getAssetName(originalFileName): # Precondition: filePath is a valid path to a asset currently checked out. # Returns the name of the asset split from the path. filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) checkinDest = amu.getCheckinDest(filePath) return os.path.basename(os.path.dirname(checkinDest))
def getAssetVersions(originalFileName): filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) checkInDest = amu.getCheckinDest(filePath) versionFolders = os.path.join(checkInDest, "src") selections = glob.glob(os.path.join(versionFolders, '*')) for i in range(0, len(selections)): selections[i] = os.path.basename(selections[i]) # Strip the path so its just the version number. return selections
def getVersionComment(assetVersion, originalFileName): # Gets the comment of that version from the .nodeInfo file. filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) checkInDest = amu.getCheckinDest(filePath) return amu.getVersionComment(checkInDest, assetVersion)
def getCheckoutDest(coPath): # Returns the checkout destination path - inside the user's directory. nodeInfo = ConfigParser() nodeInfo.read(os.path.join(coPath, ".nodeInfo")) version = nodeInfo.get("Versioning", "latestversion") return os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(coPath)) + "_" + os.path.basename(coPath) + "_" + ("%03d" % int(version)))
def getAssetVersions(originalFileName): filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) checkInDest = amu.getCheckinDest(filePath) versionFolders = os.path.join(checkInDest, "src") selections = glob.glob(os.path.join(versionFolders, '*')) for i in range(0, len(selections)): selections[i] = os.path.basename( selections[i]) # Strip the path so its just the version number. return selections
def rollback(originalFileName, destpath, correctCheckoutDir): # Move to the correct checkout directory. if not destpath==correctCheckoutDir: if os.path.exists(correctCheckoutDir): shutil.rmtree(correctCheckoutDir) os.rename(destpath, correctCheckoutDir) # Return the path to the file name. filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) checkinDest = amu.getCheckinDest(filePath) return os.path.join(correctCheckoutDir, amu.get_filename(checkinDest))
def tempSetVersion(originalFileName, version): """ Temporarily sets the 'latest version' as the specified version without deleting later versions Returns the version number that we override @precondition 'original_file_name' is a valid file name """ # I wanted this to be the originalFileName instead of the path to it, but we need a place to get the pathname. filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) print "tempSetVersion filePath: ", filePath toCheckout = amu.getCheckinDest(filePath) return amu.tempSetVersion(toCheckout, version)
def tempSetVersion(originalFileName, version): """ Temporarily sets the 'latest version' as the specified version without deleting later versions Returns the version number that we override @precondition 'original_file_name' is a valid file name """ # I wanted this to be the originalFileName instead of the path to it, but we need a place to get the pathname. filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) print "tempSetVersion filePath: ", filePath toCheckout = amu.getCheckinDest(filePath) return amu.tempSetVersion(toCheckout, version)
def build_alembic_filepath(self, refPath, filePath): # This builds the location where the alembic file will be stored. This definitely needs to be moved. #Get Shot Directory # filePath = cmds.file(q=True, sceneName=True) toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) dest = amu.getCheckinDest(toCheckin) #Get Asset Name # refPath = cmds.referenceQuery(unicode(ref), filename=True) assetName = os.path.basename(refPath).split('.')[0] return os.path.join(os.path.dirname(dest), 'animation_cache', 'abc', assetName + '.abc')
def rollback(originalFileName, destpath, correctCheckoutDir): # Move to the correct checkout directory. if not destpath == correctCheckoutDir: if os.path.exists(correctCheckoutDir): shutil.rmtree(correctCheckoutDir) os.rename(destpath, correctCheckoutDir) # Return the path to the file name. filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) checkinDest = amu.getCheckinDest(filePath) return os.path.join(correctCheckoutDir, amu.get_filename(checkinDest))
def discard(filePath): """ Discards a local checked out folder without creating a new version. """ toDiscard = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print "toDiscard: ", toDiscard chkoutInfo = ConfigParser() chkoutInfo.read(os.path.join(toDiscard, ".checkoutInfo")) chkInDest = chkoutInfo.get("Checkout", "checkedoutfrom") nodeInfo = ConfigParser() nodeInfo.read(os.path.join(chkInDest, ".nodeInfo")) nodeInfo.set("Versioning", "locked", "False") amu._writeConfigFile(os.path.join(chkInDest, ".nodeInfo"), nodeInfo) shutil.rmtree(toDiscard) if(os.path.exists(toDiscard)): os.rmdir(toDiscard)
def getAssetType(originalFileName): # This gets back the file's asset type. Necessary for buttons that don't have a context(menus) to help us know, like rollback. filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) toCheckin = amu.getCheckinDest(filePath) print "toCheckout: ", toCheckin # Need to distinguish between previs and animation. These are actually located on the third directory up, not the most recent one. assetType = os.path.basename(toCheckin).capitalize() # Prepping this for checking out. if assetType == 'Model' or assetType == 'Rig': return assetType else: # Otherwise check if it is Previs. assetType = os.path.basename(os.path.dirname(os.path.dirname(toCheckin))).capitalize() if assetType == 'Previs': return assetType else: return 'Animation'
def discard(filePath): """ Discards a local checked out folder without creating a new version. """ toDiscard = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print "toDiscard: ", toDiscard chkoutInfo = ConfigParser() chkoutInfo.read(os.path.join(toDiscard, ".checkoutInfo")) chkInDest = chkoutInfo.get("Checkout", "checkedoutfrom") nodeInfo = ConfigParser() nodeInfo.read(os.path.join(chkInDest, ".nodeInfo")) nodeInfo.set("Versioning", "locked", "False") amu._writeConfigFile(os.path.join(chkInDest, ".nodeInfo"), nodeInfo) shutil.rmtree(toDiscard) if (os.path.exists(toDiscard)): os.rmdir(toDiscard)
def getAssetType(originalFileName): # This gets back the file's asset type. Necessary for buttons that don't have a context(menus) to help us know, like rollback. filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) toCheckin = amu.getCheckinDest(filePath) print "toCheckout: ", toCheckin # Need to distinguish between previs and animation. These are actually located on the third directory up, not the most recent one. assetType = os.path.basename( toCheckin).capitalize() # Prepping this for checking out. if assetType == 'Model' or assetType == 'Rig': return assetType else: # Otherwise check if it is Previs. assetType = os.path.basename( os.path.dirname(os.path.dirname(toCheckin))).capitalize() if assetType == 'Previs': return assetType else: return 'Animation'
def isCheckedOutByMe(filePath): toDiscard = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) return amu.isCheckedOutCopyFolder(toDiscard)
def getCheckinDest(originalFileName): filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) print "tempSetVersion filePath: ", filePath return amu.getCheckinDest(filePath)
def getAssetName(originalFileName): # Precondition: filePath is a valid path to a asset currently checked out. # Returns the name of the asset split from the path. filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) checkinDest = amu.getCheckinDest(filePath) return os.path.basename(os.path.dirname(checkinDest))
def getCheckinDest(originalFileName): filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(originalFileName))) print "tempSetVersion filePath: ", filePath return amu.getCheckinDest(filePath)