def checkout(coPath, lock): """ Copies the 'latest version' from the src folder into the local directory @precondition: coAsset is the name of an actual asset @precondition: lock is a boolean value @postcondition: A copy of the 'latest version' will be placed in the local directory with the name of the versioned folder @postcondition: If lock == True coPath will be locked until it is released by checkin """ print "in checkoutDAO, running checkout" print "coPath ", coPath # First need to grab the path file first. #if not os.path.exists(os.path.join(coPath, ".nodeInfo")): if not amu.isVersionedFolder(coPath): raise Exception("Not a versioned folder.") nodeInfo = ConfigParser() nodeInfo.read(os.path.join(coPath, ".nodeInfo")) if nodeInfo.get( "Versioning", "locked" ) == "False": # Isn't this the point of the isCheckedOut method?? version = nodeInfo.getint("Versioning", "latestversion") toCopy = os.path.join(coPath, "src", "v" + ("%03d" % version)) dest = getCheckoutDest(coPath) if (os.path.exists(toCopy)): try: shutil.copytree( toCopy, dest ) # Make the copy. Note that dest (user's checkout directory) MUST NOT exist for this to work. except Exception: print "checkoutDAO, checkout: Could not copy files." raise Exception("Could not copy files.") timestamp = time.strftime("%a, %d %b %Y %I:%M:%S %p", time.localtime()) nodeInfo.set("Versioning", "lastcheckoutuser", amu.getUsername()) nodeInfo.set("Versioning", "lastcheckouttime", timestamp) nodeInfo.set("Versioning", "locked", str(lock)) amu._writeConfigFile(os.path.join(coPath, ".nodeInfo"), nodeInfo) amu._createCheckoutInfoFile(dest, coPath, version, timestamp, lock) else: raise Exception("Version doesn't exist " + toCopy) else: whoLocked = nodeInfo.get("Versioning", "lastcheckoutuser") whenLocked = nodeInfo.get("Versioning", "lastcheckouttime") logname, realname = amu.lockedBy(whoLocked) whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n' raise Exception("Can not checkout. Folder is locked by:\n\n" + whoLocked + "\nat " + whenLocked) return dest
def isShotCheckedOut(currentlySelected, currentIndex): # Checks to see if a shot can be renamed. dirPath = buildDirPath(currentIndex) coPath = dirPath + currentlySelected + '/animation'; coPath = str(coPath); if not amu.isVersionedFolder(coPath): raise Exception("Not a versioned folder."); if amu.isCheckedOut(coPath): # If it isn't checkout out, it's free to rename. return False else: return True
def isShotCheckedOut(currentlySelected, currentIndex): # Checks to see if a shot can be renamed. dirPath = buildDirPath(currentIndex) coPath = dirPath + currentlySelected + '/animation' coPath = str(coPath) if not amu.isVersionedFolder(coPath): raise Exception("Not a versioned folder.") if amu.isCheckedOut( coPath): # If it isn't checkout out, it's free to rename. return False else: return True
def checkout(coPath, lock): """ Copies the 'latest version' from the src folder into the local directory @precondition: coAsset is the name of an actual asset @precondition: lock is a boolean value @postcondition: A copy of the 'latest version' will be placed in the local directory with the name of the versioned folder @postcondition: If lock == True coPath will be locked until it is released by checkin """ print "in checkoutDAO, running checkout" print "coPath ", coPath # First need to grab the path file first. #if not os.path.exists(os.path.join(coPath, ".nodeInfo")): if not amu.isVersionedFolder(coPath): raise Exception("Not a versioned folder.") nodeInfo = ConfigParser() nodeInfo.read(os.path.join(coPath, ".nodeInfo")) if nodeInfo.get("Versioning", "locked") == "False": # Isn't this the point of the isCheckedOut method?? version = nodeInfo.getint("Versioning", "latestversion") toCopy = os.path.join(coPath, "src", "v"+("%03d" % version)) dest = getCheckoutDest(coPath) if(os.path.exists(toCopy)): try: shutil.copytree(toCopy, dest) # Make the copy. Note that dest (user's checkout directory) MUST NOT exist for this to work. except Exception: print "checkoutDAO, checkout: Could not copy files." raise Exception("Could not copy files.") timestamp = time.strftime("%a, %d %b %Y %I:%M:%S %p", time.localtime()) nodeInfo.set("Versioning", "lastcheckoutuser", amu.getUsername()) nodeInfo.set("Versioning", "lastcheckouttime", timestamp) nodeInfo.set("Versioning", "locked", str(lock)) amu._writeConfigFile(os.path.join(coPath, ".nodeInfo"), nodeInfo) amu._createCheckoutInfoFile(dest, coPath, version, timestamp, lock) else: raise Exception("Version doesn't exist "+toCopy) else: whoLocked = nodeInfo.get("Versioning", "lastcheckoutuser") whenLocked = nodeInfo.get("Versioning", "lastcheckouttime") logname, realname = amu.lockedBy(whoLocked) whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n' raise Exception("Can not checkout. Folder is locked by:\n\n"+ whoLocked+"\nat "+ whenLocked) return dest