def checkinLightingFile(): print('checkin lighting file') filepath = hou.hipFile.path() toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filepath))) backups = os.path.join(toCheckin, 'backup') print 'backup = ' + backups if os.path.isdir(backups): os.system('rm -rf ' + backups) if amu.canCheckin(toCheckin): response = hou.ui.readInput("What did you change?", buttons=( 'OK', 'Cancel', ), title='Comment') if (response[0] != 0): return comment = response[1] hou.hipFile.save() hou.hipFile.clear() amu.setComment(toCheckin, comment) dest = amu.checkin(toCheckin) srcFile = amu.getAvailableInstallFiles(dest)[0] amu.install(dest, srcFile) else: hou.ui.displayMessage('Checkin Failed')
def go(): filePath = cmds.file(q=True, sceneName=True) toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) toCheckout = amu.getCheckinDest(toCheckin) maya_checkin.checkin() try: destpath = amu.checkout(toCheckout, True) except Exception as e: print str(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) filename = os.path.basename(os.path.dirname( toCheckout)) + '_' + os.path.basename(toCheckout) + '.mb' toOpen = os.path.join(destpath, filename) # open the file if os.path.exists(toOpen): cmds.file(toOpen, force=True, open=True) #, loadReferenceDepth="none") else: # create new file cmds.file(force=True, new=True) cmds.file(rename=toOpen) cmds.viewClipPlane('perspShape', ncp=0.01) cmds.file(save=True, force=True)
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 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 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 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 checkin(): print 'checkin' saveFile() # save the file before doing anything print 'save' filePath = cmds.file(q=True, sceneName=True) print 'filePath: ' + filePath toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print 'toCheckin: ' + toCheckin if amu.canCheckin(toCheckin): comment = 'Comment' commentPrompt = cmds.promptDialog(title='Comment', message='What changes did you make?', button=['OK', 'Cancel'], defaultButton='OK', dismissString='Cancel', sf=True) if commentPrompt == 'OK': comment = cmds.promptDialog(query=True, text=True) else: return amu.setComment(toCheckin, comment) dest = amu.getCheckinDest(toCheckin) saveFile() cmds.file(force=True, new=True) #open new file dest = amu.checkin(toCheckin) #checkin else: showFailDialog()
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 checkin(): print "checkin" saveFile() # save the file before doing anything print "save" filePath = cmds.file(q=True, sceneName=True) print "filePath: " + filePath toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print "toCheckin: " + toCheckin toInstall = isRigAsset() specialInstallFiles = [os.path.join(os.environ["SHOTS_DIR"], "static/animation")] anim = isAnimationAsset() references = cmds.ls(references=True) loaded = [] if amu.canCheckin(toCheckin) and saveGeo(): # objs must be saved before checkin comment = "Comment" commentPrompt = cmds.promptDialog( title="Comment", message="What changes did you make?", button=["OK", "Cancel"], defaultButton="OK", dismissString="Cancel", sf=True, ) if commentPrompt == "OK": comment = cmds.promptDialog(query=True, text=True) else: return amu.setComment(toCheckin, comment) dest = amu.getCheckinDest(toCheckin) # if anim and showConfirmAlembicDialog() == 'Yes': # for ref in references: # if cmds.referenceQuery(ref, isLoaded=True): # loaded.append(ref) # cmds.file(unloadReference=ref) # print loaded # for ref in loaded: # cmds.file(loadReference=ref) # refPath = cmds.referenceQuery(ref, filename=True) # assetName = getAssetName(refPath) # print "\n\n\n\n**************************************************************\n" # print dest # print filePath # print refPath # print assetName # saveFile() # amu.runAlembicConverter(dest, filePath, filename=assetName) # cmds.file(unloadReference=ref) # for ref in loaded: # cmds.file(loadReference=ref) saveFile() cmds.file(force=True, new=True) # open new file dest = amu.checkin(toCheckin) # checkin toInstall |= dest in specialInstallFiles srcFile = amu.getAvailableInstallFiles(dest)[0] if toInstall: amu.install(dest, srcFile) else: showFailDialog()
def go(): filePath = cmds.file(q=True, sceneName=True) toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) toCheckout = amu.getCheckinDest(toCheckin) maya_checkin.checkin() try: destpath = amu.checkout(toCheckout, True) except Exception as e: print str(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) filename = os.path.basename(os.path.dirname(toCheckout))+'_'+os.path.basename(toCheckout)+'.mb' toOpen = os.path.join(destpath, filename) # open the file if os.path.exists(toOpen): cmds.file(toOpen, force=True, open=True)#, loadReferenceDepth="none") else: # create new file cmds.file(force=True, new=True) cmds.file(rename=toOpen) cmds.viewClipPlane('perspShape', ncp=0.01) cmds.file(save=True, force=True)
def checkin(): print 'checkin' saveFile() # save the file before doing anything print 'save' filePath = cmds.file(q=True, sceneName=True) print 'filePath: '+filePath toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print 'toCheckin: '+toCheckin if amu.canCheckin(toCheckin): comment = 'Comment' commentPrompt = cmds.promptDialog( title='Comment', message='What changes did you make?', button=['OK','Cancel'], defaultButton='OK', dismissString='Cancel', sf = True) if commentPrompt == 'OK': comment = cmds.promptDialog(query=True, text=True); else: return amu.setComment(toCheckin, comment) dest = amu.getCheckinDest(toCheckin) saveFile() cmds.file(force=True, new=True) #open new file dest = amu.checkin(toCheckin) #checkin else: showFailDialog()
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 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 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 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 checkin(): print 'checkin' saveFile() # save the file before doing anything print 'save' filePath = cmds.file(q=True, sceneName=True) print 'filePath: '+filePath toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print 'toCheckin: '+toCheckin toInstall = isRigAsset() specialInstallFiles = [os.path.join(os.environ['SHOTS_DIR'], 'static/animation')] anim = isAnimationAsset() references = cmds.ls(references=True) loaded = [] if amu.canCheckin(toCheckin) and saveGeo(): # objs must be saved before checkin comment = 'Comment' commentPrompt = cmds.promptDialog( title='Comment', message='What changes did you make?', button=['OK','Cancel'], defaultButton='OK', dismissString='Cancel', sf = True) if commentPrompt == 'OK': comment = cmds.promptDialog(query=True, text=True); else: return amu.setComment(toCheckin, comment) dest = amu.getCheckinDest(toCheckin) # if anim and showConfirmAlembicDialog() == 'Yes': # for ref in references: # if cmds.referenceQuery(ref, isLoaded=True): # loaded.append(ref) # cmds.file(unloadReference=ref) # print loaded # for ref in loaded: # cmds.file(loadReference=ref) # refPath = cmds.referenceQuery(ref, filename=True) # assetName = getAssetName(refPath) # print "\n\n\n\n**************************************************************\n" # print dest # print filePath # print refPath # print assetName # saveFile() # amu.runAlembicConverter(dest, filePath, filename=assetName) # cmds.file(unloadReference=ref) # for ref in loaded: # cmds.file(loadReference=ref) saveFile() cmds.file(force=True, new=True) #open new file dest = amu.checkin(toCheckin) #checkin toInstall |= (dest in specialInstallFiles) srcFile = amu.getAvailableInstallFiles(dest)[0] if toInstall: amu.install(dest, srcFile) else: showFailDialog()
def show_version_info(self): asset_version = str(self.current_item.text()) filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME))) checkInDest = amu.getCheckinDest(filePath) comment = amu.getVersionComment(checkInDest, asset_version) self.version_info_label.setText(comment)
def refresh(self): filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME))) checkInDest = amu.getCheckinDest(filePath) versionFolders = os.path.join(checkInDest, "src") selections = glob.glob(os.path.join(versionFolders, '*')) self.update_selection(selections)
def rollback(self): dialogResult = self.showWarningDialog() if dialogResult == 'Yes': version = str(self.current_item.text())[1:] dirPath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME))) print dirPath cmd.file(force=True, new=True) amu.setVersion(dirPath, int(version)) self.close()
def checkin(): print 'checkin' saveFile() # save the file before doing anything print 'save' filePath = cmds.file(q=True, sceneName=True) print 'filePath: '+filePath toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print 'toCheckin: '+toCheckin rig = isRigAsset() anim = isAnimationAsset() references = cmds.ls(references=True) loaded = [] if amu.canCheckin(toCheckin) and saveGeo(): # objs must be saved before checkin comment = 'Comment' commentPrompt = cmds.promptDialog( title='Comment', message='What changes did you make?', button=['OK','Cancel'], defaultButton='OK', dismissString='Cancel', sf = True) if commentPrompt == 'OK': comment = cmds.promptDialog(query=True, text=True); else: return amu.setComment(toCheckin, comment) dest = amu.getCheckinDest(toCheckin) # if anim and showConfirmAlembicDialog() == 'Yes': # for ref in references: # if cmds.referenceQuery(ref, isLoaded=True): # loaded.append(ref) # cmds.file(unloadReference=ref) # print loaded # for ref in loaded: # cmds.file(loadReference=ref) # refPath = cmds.referenceQuery(ref, filename=True) # assetName = getAssetName(refPath) # print "\n\n\n\n**************************************************************\n" # print dest # print filePath # print refPath # print assetName # saveFile() # amu.runAlembicConverter(dest, filePath, filename=assetName) # cmds.file(unloadReference=ref) # for ref in loaded: # cmds.file(loadReference=ref) saveFile() cmds.file(force=True, new=True) #open new file dest = amu.checkin(toCheckin) #checkin srcFile = amu.getAvailableInstallFiles(dest)[0] if rig: amu.install(dest, srcFile) else: showFailDialog()
def checkinLightingFile(): print 'checkin lighting file' filepath = hou.hipFile.path() toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filepath))) if amu.canCheckin(toCheckin): hou.hipFile.save() hou.hipFile.clear() dest = amu.checkin(toCheckin) else: ui.infoWindow('Checkin Failed')
def rollback(self): dialogResult = self.show_warning_dialog() if dialogResult == 'Yes': version = str(self.current_item.text())[1:] dirPath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME))) print dirPath cmd.file(force=True, new=True) amu.setVersion(dirPath, int(version)) self.close()
def checkin(): filePath = nuke.callbacks.filenameFilter( nuke.root().name() ) save = nuke.scriptSave() if save==True: toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) if amu.canCheckin(toCheckin): dest = amu.checkin(toCheckin, False) nuke.message('Checkin Successful!') nuke.scriptClose() else: nuke.message('Can not check in')
def build_alembic_filepath(self, ref): #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 open_version(self): filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME))) checkInDest = amu.getCheckinDest(filePath) v = str(self.current_item.text()) checkinPath = os.path.join(checkInDest, "src", v) checkinName = os.path.join(checkinPath, os.path.basename(self.ORIGINAL_FILE_NAME)) print checkinName if os.path.exists(checkinName): cmd.file(checkinName, force=True, open=True) else: self.show_no_file_dialog()
def checkinLightingFile(): print("checkin lighting file") filepath = hou.hipFile.path() toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filepath))) if amu.canCheckin(toCheckin): hou.hipFile.save() hou.hipFile.clear() dest = amu.checkin(toCheckin, False) srcFile = amu.getAvailableInstallFiles(dest)[0] amu.install(dest, srcFile) else: ui.infoWindow("Checkin Failed")
def checkin(): filePath = nuke.callbacks.filenameFilter(nuke.root().name()) save = nuke.scriptSave() if save == True: toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) if amu.canCheckin(toCheckin): dest = amu.checkin(toCheckin, False) nuke.message('Checkin Successful!') nuke.scriptClose() else: nuke.message('Can not check in')
def build_alembic_filepath(self, ref): #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 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 go(): currentFile = cmd.file(query=True, sceneName=True) filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(currentFile))) if(amu.isCheckedOutCopyFolder(filePath)): cmd.file(save=True, force=True) dialog = RollbackDialog() dialog.show() else: cmd.confirmDialog( title = 'Invalid Command' , message = 'This is not a checked out file. There is nothing to rollback.' , button = ['Ok'] , defaultButton = 'Ok' , cancelButton = 'Ok' , dismissString = 'Ok')
def export_alembic(): print "Exporting Alembic" saveFile() filePath = cmds.file(q=True, sceneName=True) toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) dest = amu.getCheckinDest(toCheckin) references = cmds.ls(references=True) loaded = [] for ref in references: if cmds.referenceQuery(ref, isLoaded=True): loaded.append(ref) cmds.file(unloadReference=ref) if showConfirmAlembicDialog(loaded) == 'Yes': print loaded for ref in loaded: print "\n\n\n\n**************************************************************\n" constraints = [] #TODO refactor the controller stuff to work with a 'prop list' it will scale easier if 'controller' in ref: for c in loaded: if 'owned_tommy_rig_stable' in c or 'owned_abby_rig_stable' in c or 'owned_jeff_rig_stable' in c: constraints.append(c) cmds.file(loadReference=ref) for c in constraints: print c cmds.file(loadReference=c) refPath = cmds.referenceQuery(ref, filename=True) assetName = getAssetName(refPath) print dest print filePath print refPath print assetName saveFile() abcfilepath = os.path.join(os.path.dirname(dest), 'animation_cache', 'abc', assetName + '.abc') convert(abcfilepath) cmds.file(unloadReference=ref) for ref in loaded: cmds.file(loadReference=ref)
def checkin(): print 'checkin' saveFile() # save the file before doing anything print 'save' filePath = cmds.file(q=True, sceneName=True) print 'filePath: ' + filePath toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print 'toCheckin: ' + toCheckin rig = isRigAsset() anim = isAnimationAsset() references = cmds.ls(references=True) loaded = [] if amu.canCheckin( toCheckin) and saveGeo(): # objs must be saved before checkin dest = amu.getCheckinDest(toCheckin) # if anim and showConfirmAlembicDialog() == 'Yes': # for ref in references: # if cmds.referenceQuery(ref, isLoaded=True): # loaded.append(ref) # cmds.file(unloadReference=ref) # print loaded # for ref in loaded: # cmds.file(loadReference=ref) # refPath = cmds.referenceQuery(ref, filename=True) # assetName = getAssetName(refPath) # print "\n\n\n\n**************************************************************\n" # print dest # print filePath # print refPath # print assetName # saveFile() # amu.runAlembicConverter(dest, filePath, filename=assetName) # cmds.file(unloadReference=ref) # for ref in loaded: # cmds.file(loadReference=ref) saveFile() cmds.file(force=True, new=True) #open new file dest = amu.checkin(toCheckin, anim or rig or os.path.basename(os.path.dirname(filePath))[:32] == 'owned_jeff_apartment_walls_model') #checkin srcFile = amu.getAvailableInstallFiles(dest)[0] if rig: amu.install(dest, srcFile) else: showFailDialog()
def checkinLightingFile(): print ("checkin lighting file") filepath = hou.hipFile.path() toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filepath))) backups = os.path.join(toCheckin, "backup") print "backup = " + backups if os.path.isdir(backups): os.system("rm -rf " + backups) if amu.canCheckin(toCheckin): hou.hipFile.save() hou.hipFile.clear() dest = amu.checkin(toCheckin, False) srcFile = amu.getAvailableInstallFiles(dest)[0] amu.install(dest, srcFile) else: hou.ui.displayMessage("Checkin Failed")
def open_version(self): dialogResult = self.verify_open_version_dialog() if (dialogResult == 'Ok'): filePath = os.path.join( amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME))) checkInDest = amu.getCheckinDest(filePath) v = str(self.current_item.text()) checkinPath = os.path.join(checkInDest, "src", v) checkinName = os.path.join( checkinPath, os.path.basename(self.ORIGINAL_FILE_NAME)) print checkinName if os.path.exists(checkinName): cmd.file(checkinName, force=True, open=True) else: self.show_no_file_dialog()
def checkinLightingFile(): print('checkin lighting file') filepath = hou.hipFile.path() toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filepath))) backups = os.path.join(toCheckin, 'backup') print 'backup = ' + backups if os.path.isdir(backups): os.system('rm -rf '+backups) if amu.canCheckin(toCheckin): hou.hipFile.save() hou.hipFile.clear() dest = amu.checkin(toCheckin, False) srcFile = amu.getAvailableInstallFiles(dest)[0] amu.install(dest, srcFile) else: ui.infoWindow('Checkin Failed')
def checkin(): print 'checkin' saveFile() # save the file before doing anything print 'save' filePath = cmds.file(q=True, sceneName=True) print 'filePath: '+filePath toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print 'toCheckin: '+toCheckin rig = isRigAsset() if amu.canCheckin(toCheckin) and saveGeo(): # objs must be saved before checkin cmds.file(force=True, new=True) #open new file dest = amu.checkin(toCheckin) #checkin if rig: srcFile = amu.getAvailableInstallFiles(dest)[0] amu.install(dest, srcFile) else: showFailDialog()
def export_alembic(): print "Exporting Alembic" saveFile() filePath = cmds.file(q=True, sceneName=True) toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) dest = amu.getCheckinDest(toCheckin) references = cmds.ls(references=True) loaded = [] for ref in references: if cmds.referenceQuery(ref, isLoaded=True): loaded.append(ref) cmds.file(unloadReference=ref) if showConfirmAlembicDialog(loaded) == "Yes": print loaded for ref in loaded: print "\n\n\n\n**************************************************************\n" constraints = [] # TODO refactor the controller stuff to work with a 'prop list' it will scale easier if "controller" in ref: for c in loaded: if "owned_tommy_rig_stable" in c or "owned_abby_rig_stable" in c or "owned_jeff_rig_stable" in c: constraints.append(c) cmds.file(loadReference=ref) for c in constraints: print c cmds.file(loadReference=c) refPath = cmds.referenceQuery(ref, filename=True) assetName = getAssetName(refPath) print dest print filePath print refPath print assetName saveFile() abcfilepath = os.path.join(os.path.dirname(dest), "animation_cache", "abc", assetName + ".abc") convert(abcfilepath) cmds.file(unloadReference=ref) for ref in loaded: cmds.file(loadReference=ref)
def checkin(): print 'checkin' saveFile() # save the file before doing anything print 'save' filePath = cmds.file(q=True, sceneName=True) print 'filePath: '+filePath toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print 'toCheckin: '+toCheckin rig = isRigAsset() anim = isAnimationAsset() references = cmds.ls(references=True) loaded = [] if amu.canCheckin(toCheckin) and saveGeo(): # objs must be saved before checkin dest = amu.getCheckinDest(toCheckin) # if anim and showConfirmAlembicDialog() == 'Yes': # for ref in references: # if cmds.referenceQuery(ref, isLoaded=True): # loaded.append(ref) # cmds.file(unloadReference=ref) # print loaded # for ref in loaded: # cmds.file(loadReference=ref) # refPath = cmds.referenceQuery(ref, filename=True) # assetName = getAssetName(refPath) # print "\n\n\n\n**************************************************************\n" # print dest # print filePath # print refPath # print assetName # saveFile() # amu.runAlembicConverter(dest, filePath, filename=assetName) # cmds.file(unloadReference=ref) # for ref in loaded: # cmds.file(loadReference=ref) saveFile() cmds.file(force=True, new=True) #open new file dest = amu.checkin(toCheckin, anim or rig or os.path.basename(os.path.dirname(filePath))[:32]=='owned_jeff_apartment_walls_model') #checkin srcFile = amu.getAvailableInstallFiles(dest)[0] if rig: amu.install(dest, srcFile) else: showFailDialog()
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 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 checkin(): print 'checkin' saveFile() # save the file before doing anything print 'save' filePath = cmds.file(q=True, sceneName=True) print 'filePath: '+filePath toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath))) print 'toCheckin: '+toCheckin rig = isRigAsset() anim = isAnimationAsset() if amu.canCheckin(toCheckin) and saveGeo(): # objs must be saved before checkin cmds.file(force=True, new=True) #open new file dest = amu.checkin(toCheckin, anim or rig) #checkin srcFile = amu.getAvailableInstallFiles(dest)[0] if rig: amu.install(dest, srcFile) if anim and showConfirmAlembicDialog() == 'Yes': amu.runAlembicConverter(dest, srcFile) else: showFailDialog()
def checkinLightingFile(): print('checkin lighting file') filepath = hou.hipFile.path() toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filepath))) backups = os.path.join(toCheckin, 'backup') print 'backup = ' + backups if os.path.isdir(backups): os.system('rm -rf '+backups) if amu.canCheckin(toCheckin): response = hou.ui.readInput("What did you change?", buttons=('OK', 'Cancel',), title='Comment') if(response[0] != 0): return comment = response[1] hou.hipFile.save() hou.hipFile.clear() amu.setComment(toCheckin, comment) dest = amu.checkin(toCheckin) srcFile = amu.getAvailableInstallFiles(dest)[0] amu.install(dest, srcFile) else: hou.ui.displayMessage('Checkin Failed')
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 refresh(self): filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME))) checkInDest = amu.getCheckinDest(filePath) versionFolders = os.path.join(checkInDest, "src") selections = glob.glob(os.path.join(versionFolders, '*')) self.update_selection(selections)
def get_checkin_path(): filePath = get_file_path() return os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath)))
checkInDest = amu.getCheckinDest(filePath) v = str(self.current_item.text()) checkinPath = os.path.join(checkInDest, "src", v) checkinName = os.path.join(checkinPath, os.path.basename(ORIGINAL_FILE_NAME)) print checkinName if os.path.exists(checkinName): cmd.file(checkinName, force=True, open=True) else: self.show_no_file_dialog() def go(): dialog = RollbackDialog() dialog.show() if __name__ == "__main__": filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(ORIGINAL_FILE_NAME))) if amu.isCheckedOutCopyFolder(filePath): cmd.file(save=True, force=True) go() else: cmd.confirmDialog( title="Invalid Command", message="This is not a checked out file. There is nothing to rollback.", button=["Ok"], defaultButton="Ok", cancelButton="Ok", dismissString="Ok", )
def show_version_info(self): asset_version = str(self.current_item.text()) filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME))) checkInDest = amu.getCheckinDest(filePath) comment = amu.getVersionComment(checkInDest,asset_version) self.version_info_label.setText(comment)