def checkout_version(self): dialogResult = self.verify_checkout_dialog() if(dialogResult == 'Yes'): #checkout version = str(self.current_item.text())[1:] filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME))) toCheckout = amu.getCheckinDest(filePath) latestVersion = amu.tempSetVersion(toCheckout, version) amu.discard(filePath) try: destpath = amu.checkout(toCheckout, True) except Exception as e: if not amu.checkedOutByMe(toCheckout): cmd.confirmDialog( title = 'Can Not Checkout' , message = str(e) , button = ['Ok'] , defaultButton = 'Ok' , cancelButton = 'Ok' , dismissString = 'Ok') return else: destpath = amu.getCheckoutDest(toCheckout) toOpen = os.path.join(destpath, self.get_filename(toCheckout)+'.mb') self.ORIGINAL_FILE_NAME = toOpen amu.tempSetVersion(toCheckout, latestVersion) if not os.path.exists(toOpen): # create new file cmd.file(force=True, new=True) cmd.file(rename=toOpen) cmd.file(save=True, force=True) self.close_dialog()
def discardLightingFile(): filepath = hou.hipFile.path() # TODO print (filepath) if ( hou.ui.displayMessage( "YOU ARE ABOUT TO IRREVOKABLY DISCARD ALL CHANGES YOU HAVE MADE. " "Please think this through very carefully.\n " "Are you sure you want to discard " "your changes?", buttons=("Yes", "No"), default_choice=1, title="Discard Confirmation", ) == 0 ): toDiscard = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filepath))) if amu.isCheckedOutCopyFolder(toDiscard): hou.hipFile.clear() amu.discard(toDiscard) else: hou.ui.displayMessage( "This is not a checked out file. There is nothing to discard", title="Invalid Command" ) else: hou.ui.displayMessage("Thank you for being responsible.", title="Discard Cancelled")
def rollbackShotFilesGo(answer,versionedFolders,asset_name,toCheckout): if answer: version = int(answer[1:]) versionStr = "%03d" % version rollingBack = hou.ui.displayMessage('WARNING: You are about to remove your most recent changes. Proceed at your own risk.', buttons=('Actually, I don\'t want to', 'Yes. Roll me back'), severity=hou.severityType.Warning, title=("Woah there, pardner!")) if (rollingBack): newLighting = os.path.join(versionedFolders, "v" + versionStr) # Again: set the latest version in the .nodeInfo file to the selected version, and checkout the next version. #asset_name, ext = os.path.splitext(filename) checkoutFilePath = os.path.join(amu.getUserCheckoutDir(), (asset_name[0]+"_lighting")) oldVersion = int(amu.tempSetVersion(toCheckout, version)) oldVersionStr = "%03d" % oldVersion tempFilePath = os.path.join(checkoutFilePath + "_" + versionStr) filePath = os.path.join(checkoutFilePath + "_" + oldVersionStr) # Discard the old file, and check out the rollbacked one. amu.discard(filePath) # Hey! This is working!!! amu.checkout(toCheckout, True) # Then resetting the version number back to the most recent, so when we check in again, we will be in the most recent version. amu.tempSetVersion(toCheckout, oldVersion) correctCheckoutDest = amu.getCheckoutDest(toCheckout) #print "correctCheckoutDest ", correctCheckoutDest os.rename(tempFilePath, correctCheckoutDest)
def discardLightingFile(): filepath = hou.hipFile.path() #TODO print(filepath) if hou.ui.displayMessage( 'YOU ARE ABOUT TO IRREVOKABLY DISCARD ALL CHANGES YOU HAVE MADE. ' 'Please think this through very carefully.\n ' 'Are you sure you want to discard ' 'your changes?', buttons=( 'Yes', 'No', ), default_choice=1, title='Discard Confirmation') == 0: toDiscard = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filepath))) if amu.isCheckedOutCopyFolder(toDiscard): hou.hipFile.clear() amu.discard(toDiscard) else: hou.ui.displayMessage( 'This is not a checked out file. There is nothing to discard', title='Invalid Command') else: hou.ui.displayMessage('Thank you for being responsible.', title='Discard Cancelled')
def checkout_button_clicked(self): version = self.rollback_dialog.get_current_item()[1:] filePath = common.get_checkin_path() toCheckout = amu.getCheckinDest(filePath) latestVersion = amu.tempSetVersion(toCheckout, version) amu.discard(filePath) try: destpath = amu.checkout(toCheckout, True) except Exception as e: if not amu.checkedOutByMe(toCheckout): muke.message(str(e)) return else: destpath = amu.getCheckoutDest(toCheckout) amu.tempSetVersion(toCheckout, latestVersion) # move to correct checkout directory correctCheckoutDir = amu.getCheckoutDest(toCheckout) if not destpath == correctCheckoutDir: if os.path.exists(correctCheckoutDir): shutil.rmtree(correctCheckoutDir) os.rename(destpath, correctCheckoutDir) toOpen = os.path.join(correctCheckoutDir, self.get_filename(toCheckout) + '.nk') if not os.path.exists(toOpen): # create new file nuke.scriptNew() nuke.scriptSaveAs(filename=toOpen, overwrite=0) else: nuke.scriptOpen(toOpen) self.rollback_dialog.close()
def discard(filePath=cmds.file(q=True, sceneName=True)): if not filePath: return print filePath dlgResult = showWarningDialog() if dlgResult == "Yes": # get discard directory before opening new file toDiscard = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) if amu.isCheckedOutCopyFolder(toDiscard): cmds.file(force=True, new=True) # open new file amu.discard(toDiscard) # discard changes else: cmds.confirmDialog( title="Invalid Command", message="This is not a checked out file. There is nothing to discard.", button=["Ok"], defaultButton="Ok", cancelButton="Ok", dismissString="Ok", ) elif dlgResult == "Brent": brent.go() else: cmds.confirmDialog( title="Discard Cancelled", message="Thank you for being responsible.", button=["Ok"], defaultButton="Ok", cancelButton="Ok", dismissString="Ok", )
def rollbackOTLgo(answer, versionedFolders, asset_name, toCheckout): #answer = dialog.answer#hou.ui.selectFromList(selections, message='Select version to rollback:', exclusive=True) if answer: version = int(answer[1:]) versionStr = "%03d" % version newVersion = os.path.join(versionedFolders, "v" + versionStr) checkoutFilePath = os.path.join(amu.getUserCheckoutDir(), asset_name) rollingBack = hou.ui.displayMessage( 'WARNING: You are about to remove your most recent changes. Proceed at your own risk.', buttons=('Actually, I don\'t want to', 'Yes. Roll me back'), severity=hou.severityType.Warning, title=("Woah there, pardner!")) if (rollingBack): print "rollingBack" # Temporarily set the version to the rollback version, and check out. oldVersion = int(amu.tempSetVersion(toCheckout, versionStr)) oldVersionStr = "%03d" % oldVersion print toCheckout tempFilePath = os.path.join(checkoutFilePath + "_otl_" + versionStr) filePath = os.path.join(checkoutFilePath + "_otl_" + oldVersionStr) # Now that we've set the version, we will amu.discard(filePath) # Hey! This is working!!! amu.checkout(toCheckout, True) # Reset the version number, and rename the checkout path to the most recent version. amu.tempSetVersion(toCheckout, oldVersion) correctCheckoutDest = amu.getCheckoutDest(toCheckout) os.rename(tempFilePath, correctCheckoutDest)
def discard(): filePath = cmds.file(q=True, sceneName=True) if not filePath: return dlgResult = showWarningDialog() if dlgResult == 'Yes': # get discard directory before opening new file toDiscard = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) if (amu.isCheckedOutCopyFolder(toDiscard)): cmds.file(force=True, new=True) #open new file amu.discard(toDiscard) # discard changes else: cmds.confirmDialog( title='Invalid Command', message= 'This is not a checked out file. There is nothing to discard.', button=['Ok'], defaultButton='Ok', cancelButton='Ok', dismissString='Ok') elif dlgResult == 'Brent': brent.go() else: cmds.confirmDialog(title='Discard Cancelled', message='Thank you for being responsible.', button=['Ok'], defaultButton='Ok', cancelButton='Ok', dismissString='Ok')
def rollbackOTLgo(answer,versionedFolders,asset_name,toCheckout): #answer = dialog.answer#hou.ui.selectFromList(selections, message='Select version to rollback:', exclusive=True) if answer: version = int(answer[1:]) versionStr = "%03d" % version newVersion = os.path.join(versionedFolders,"v" + versionStr) checkoutFilePath = os.path.join(amu.getUserCheckoutDir(), asset_name) rollingBack = hou.ui.displayMessage('WARNING: You are about to remove your most recent changes. Proceed at your own risk.', buttons=('Actually, I don\'t want to', 'Yes. Roll me back'), severity=hou.severityType.Warning, title=("Woah there, pardner!")) if (rollingBack): print "rollingBack" # Temporarily set the version to the rollback version, and check out. oldVersion = int(amu.tempSetVersion(toCheckout, versionStr)) oldVersionStr = "%03d" % oldVersion print toCheckout tempFilePath = os.path.join(checkoutFilePath + "_otl_" + versionStr) filePath = os.path.join(checkoutFilePath + "_otl_" + oldVersionStr) # Now that we've set the version, we will amu.discard(filePath) # Hey! This is working!!! amu.checkout(toCheckout, True) # Reset the version number, and rename the checkout path to the most recent version. amu.tempSetVersion(toCheckout, oldVersion) correctCheckoutDest = amu.getCheckoutDest(toCheckout) os.rename(tempFilePath, correctCheckoutDest)
def checkout_button_clicked(self): version = self.rollback_dialog.get_current_item()[1:] filePath = common.get_checkin_path() toCheckout = amu.getCheckinDest(filePath) latestVersion = amu.tempSetVersion(toCheckout, version) amu.discard(filePath) try: destpath = amu.checkout(toCheckout, True) except Exception as e: if not amu.checkedOutByMe(toCheckout): muke.message(str(e)) return else: destpath = amu.getCheckoutDest(toCheckout) amu.tempSetVersion(toCheckout, latestVersion) # move to correct checkout directory correctCheckoutDir = amu.getCheckoutDest(toCheckout) if not destpath == correctCheckoutDir: if os.path.exists(correctCheckoutDir): shutil.rmtree(correctCheckoutDir) os.rename(destpath, correctCheckoutDir) toOpen = os.path.join(correctCheckoutDir, self.get_filename(toCheckout)+'.nk') if not os.path.exists(toOpen): # create new file nuke.scriptNew() nuke.scriptSaveAs(filename=toOpen, overwrite=0) else: nuke.scriptOpen(toOpen) self.rollback_dialog.close()
def discard(): filePath=cmds.file(q=True, sceneName=True) if not filePath: return dlgResult = showWarningDialog() if dlgResult == 'Yes': # get discard directory before opening new file toDiscard = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) if(amu.isCheckedOutCopyFolder(toDiscard)): cmds.file(force=True, new=True) #open new file amu.discard(toDiscard) # discard changes else: cmds.confirmDialog( title = 'Invalid Command' , message = 'This is not a checked out file. There is nothing to discard.' , button = ['Ok'] , defaultButton = 'Ok' , cancelButton = 'Ok' , dismissString = 'Ok') elif dlgResult == 'Brent': return else: cmds.confirmDialog( title = 'Discard Cancelled' , message = 'Thank you for being responsible.' , button = ['Ok'] , defaultButton = 'Ok' , cancelButton = 'Ok' , dismissString = 'Ok')
def discard(node = None): if not isDigitalAsset(node): hou.ui.displayMessage("Not a Digital Asset.") else: libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) toDiscard = os.path.dirname(libraryPath) if amu.isCheckedOutCopyFolder(toDiscard): switchOPLibraries(libraryPath, os.path.join(OTLDIR, filename)) node.matchCurrentDefinition() amu.discard(toDiscard) hou.ui.displayMessage("Revert Successful!")
def discard(): file_path = get_file_path() if file_path: toDiscard = get_checkin_path() if amu.isCheckedOutCopyFolder(toDiscard): if show_confirm_dialog(): nuke.scriptClear() amu.discard(toDiscard) else: show_dialog('ERROR: Not checked out.') else: show_dialog('ERROR: Not a file.')
def discard(node=None): if not isDigitalAsset(node): hou.ui.displayMessage("Not a Digital Asset.") else: libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) toDiscard = os.path.dirname(libraryPath) if amu.isCheckedOutCopyFolder(toDiscard): switchOPLibraries(libraryPath, os.path.join(OTLDIR, filename)) node.matchCurrentDefinition() amu.discard(toDiscard) hou.ui.displayMessage("Revert Successful!")
def rollbackShotFiles(): # NOTE: Currently, we do not "check out" a shot file when it is pulled in. That is interesting. I wonder why not? Anyway, I don't know if that is an issue yet. Ah well. I guess we'll play with it. print "RollbackShotFiles" filepath = hou.hipFile.path() # The filepath goes to the path for the checked out file in the user directory. filename = os.path.basename(filepath) if not (filename == "untitled.hip"):\ # If it isn't untitled, then we have a checked out lighting file, and we will proceed. shotNumber = filename.split("_"); shotPaths = os.path.join(SHOTSDIR, str(shotNumber[0])) lightingPath = os.path.join(shotPaths, "lighting") lightingSrc = os.path.join(lightingPath, "src") versions = glob.glob(os.path.join(lightingSrc, "*")) versionList = [] for v in versions: versionList.append(os.path.basename(v)) versionList.sort() # Should only be one. Whatever. answer = hou.ui.selectFromList(versionList, message='Select lighting version to rollback:', exclusive=True) if answer: version = answer[0] versionStr = "%03d" % version rollingBack = hou.ui.displayMessage('WARNING: You are about to remove your most recent changes. Proceed at your own risk.', buttons=('Actually, I don\'t want to', 'Yes. Roll me back'), severity=hou.severityType.Warning, title=("Woah there, pardner!")) if (rollingBack): newLighting = os.path.join(lightingSrc, "v" + versionStr) # Again: set the latest version in the .nodeInfo file to the selected version, and checkout the next version. asset_name, ext = os.path.splitext(filename) checkoutFilePath = os.path.join(amu.getUserCheckoutDir(), asset_name) oldVersion = int(amu.tempSetVersion(lightingPath, version)) oldVersionStr = "%03d" % oldVersion tempFilePath = os.path.join(checkoutFilePath + "_" + versionStr) filePath = os.path.join(checkoutFilePath + "_" + oldVersionStr) # Discard the old file, and check out the rollbacked one. amu.discard(filePath) # Hey! This is working!!! amu.checkout(lightingPath, True) # Then resetting the version number back to the most recent, so when we check in again, we will be in the most recent version. amu.tempSetVersion(lightingPath, oldVersion) correctCheckoutDest = amu.getCheckoutDest(lightingPath) print "correctCheckoutDest ", correctCheckoutDest os.rename(tempFilePath, correctCheckoutDest)
def discard(filePath=cmds.file(q=True, sceneName=True)): if not filePath: return print filePath dlgResult = showWarningDialog() if dlgResult == 'Yes': toDiscard = os.path.dirname(filePath) # get discard directory before opening new file cmds.file(force=True, new=True) #open new file amu.discard(toDiscard) # discard changes elif dlgResult == 'Brent': brent.go() else: cmds.confirmDialog( title = 'Discard Cancelled' , message = 'Thank you for being responsible.' , button = ['Ok'] , defaultButton = 'Ok' , cancelButton = 'Ok' , dismissString = 'Ok')
def discardLightingFile(): filepath = hou.hipFile.path() #TODO print(filepath) if hou.ui.displayMessage('YOU ARE ABOUT TO IRREVOKABLY DISCARD ALL CHANGES YOU HAVE MADE. ' 'Please think this through very carefully.\n ' 'Are you sure you want to discard ' 'your changes?' , buttons=('Yes','No',) , default_choice=1 , title='Discard Confirmation') == 0: toDiscard = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filepath))) if amu.isCheckedOutCopyFolder(toDiscard): hou.hipFile.clear() amu.discard(toDiscard) else: hou.ui.displayMessage('This is not a checked out file. There is nothing to discard', title='Invalid Command') else: hou.ui.displayMessage('Thank you for being responsible.', title='Discard Cancelled')
def checkout_version(self): dialogResult = self.verify_checkout_dialog() if (dialogResult == 'Yes'): #checkout version = str(self.current_item.text())[1:] filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME))) toCheckout = amu.getCheckinDest(filePath) latestVersion = amu.tempSetVersion(toCheckout, version) amu.discard(filePath) try: destpath = amu.checkout(toCheckout, True) except Exception as e: if not amu.checkedOutByMe(toCheckout): cmd.confirmDialog(title='Can Not Checkout', message=str(e), button=['Ok'], defaultButton='Ok', cancelButton='Ok', dismissString='Ok') return else: destpath = amu.getCheckoutDest(toCheckout) amu.tempSetVersion(toCheckout, latestVersion) # move to correct checkout directory correctCheckoutDir = amu.getCheckoutDest(toCheckout) if not destpath == correctCheckoutDir: if os.path.exists(correctCheckoutDir): shutil.rmtree(correctCheckoutDir) os.rename(destpath, correctCheckoutDir) toOpen = os.path.join(correctCheckoutDir, self.get_filename(toCheckout) + '.mb') self.ORIGINAL_FILE_NAME = toOpen if not os.path.exists(toOpen): # create new file cmd.file(force=True, new=True) cmd.file(rename=toOpen) cmd.file(save=True, force=True) cmd.file(self.ORIGINAL_FILE_NAME, force=True, open=True) self.close_dialog()
def rollbackShotFilesGo(answer, versionedFolders, asset_name, toCheckout): if answer: version = int(answer[1:]) versionStr = "%03d" % version rollingBack = hou.ui.displayMessage( 'WARNING: You are about to remove your most recent changes. Proceed at your own risk.', buttons=('Actually, I don\'t want to', 'Yes. Roll me back'), severity=hou.severityType.Warning, title=("Woah there, pardner!")) if (rollingBack): newLighting = os.path.join(versionedFolders, "v" + versionStr) # Again: set the latest version in the .nodeInfo file to the selected version, and checkout the next version. #asset_name, ext = os.path.splitext(filename) checkoutFilePath = os.path.join(amu.getUserCheckoutDir(), (asset_name[0] + "_lighting")) oldVersion = int(amu.tempSetVersion(toCheckout, version)) oldVersionStr = "%03d" % oldVersion tempFilePath = os.path.join(checkoutFilePath + "_" + versionStr) filePath = os.path.join(checkoutFilePath + "_" + oldVersionStr) # Discard the old file, and check out the rollbacked one. amu.discard(filePath) # Hey! This is working!!! amu.checkout(toCheckout, True) # Then resetting the version number back to the most recent, so when we check in again, we will be in the most recent version. amu.tempSetVersion(toCheckout, oldVersion) correctCheckoutDest = amu.getCheckoutDest(toCheckout) #print "correctCheckoutDest ", correctCheckoutDest os.rename(tempFilePath, correctCheckoutDest)
def rollbackOTL(node = None): """Pulls a rollback window for the user to select a version to rollback to. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database. """ print 'RollbackOTL' ham.updateDB() #Need to check if a particular node is a digital asset first. Rollback is will only work as a DA, with model, rigs and animation. if node != None: if not ham.isDigitalAsset(node): ui.infoWindow('Wait! You can only rollback Digital Assets!') print "NOT A DIGITAL ASSET." else: # First, we need to see if this is checked out or not. If it is checked out, then we can proceed. If not, state so. # For the productions path libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) asset_name, ext = os.path.splitext(filename) #print "asset_name " + asset_name toCheckout = os.path.join(ASSETSDIR, asset_name, 'otl') #print "toCheckout " + toCheckout myCheckout = False myCheckout = amu.isCheckedOut(toCheckout) if myCheckout: #If it has been checked out myCheckout = amu.checkedOutByMe(toCheckout) if myCheckout: #If user was the last to checkout #Here we rollback. versionedFolders = os.path.join(toCheckout, "src") #print "versionedFolders ", versionedFolders versions = glob.glob(os.path.join(versionedFolders, '*')) #print "selections ", versions #Wooohoooo!!! selections = [] for vr in versions: selections.append(os.path.basename(vr)) selections.sort() answer = hou.ui.selectFromList(selections, message='Select version to rollback:', exclusive=True) if answer: version = answer[0] versionStr = "%03d" % version newVersion = os.path.join(versionedFolders, "v" + versionStr) checkoutFilePath = os.path.join(amu.getUserCheckoutDir(), asset_name) rollingBack = hou.ui.displayMessage('WARNING: You are about to remove your most recent changes. Proceed at your own risk.', buttons=('Actually, I don\'t want to', 'Yes. Roll me back'), severity=hou.severityType.Warning, title=("Woah there, pardner!")) if (rollingBack): print "rollingBack" # Temporarily set the version to the rollback version, and check out. oldVersion = int(amu.tempSetVersion(toCheckout, version)) oldVersionStr = "%03d" % oldVersion tempFilePath = os.path.join(checkoutFilePath + "_otl_" + versionStr) filePath = os.path.join(checkoutFilePath + "_otl_" + oldVersionStr) # Now that we've set the version, we will amu.discard(filePath) # Hey! This is working!!! amu.checkout(toCheckout, True) # Reset the version number, and rename the checkout path to the most recent version. amu.tempSetVersion(toCheckout, oldVersion) correctCheckoutDest = amu.getCheckoutDest(toCheckout) os.rename(tempFilePath, correctCheckoutDest) else: hou.ui.displayMessage('Already checked out.') return else: hou.ui.displayMessage('Please checkout asset first.') else: print "Node does not exist"