def rename(node = None): """Renames the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database. """ if node != None: if not isDigitalAsset(node): hou.ui.displayMessage("Not a Digital Asset.") else: if isContainer(node): oldlibraryPath = node.type().definition().libraryFilePath() oldfilename = os.path.basename(oldlibraryPath) oldAssetName = oldfilename.split('.')[0] assetDirPath = os.path.join(ASSETSDIR, oldAssetName) dependents = getAssetDependents(oldAssetName) if dependents: hou.ui.displayMessage('The following assets are depenent on this asset: \n\n'+printList(dependents)+'\nModify these assets first before attempting to rename again!!', title='Can NOT rename!', severity=hou.severityType.Error) return nodeDir = os.path.join(os.environ['ASSETS_DIR'], oldAssetName, 'otl') info = amu.getVersionedFolderInfo(nodeDir); if info[0] == "": if passwordWindow('r3n@m3p@ssw0rd', 'Enter the rename password...'): resp = hou.ui.readInput("Enter the New Operator Label", title="Rename OTL") if resp != None and resp[1].strip() != '': name = formatName(resp[1]) newfilename = name.replace(' ', '_') newfilepath = os.path.join(OTLDIR, newfilename+'.otl') oldfilepath = os.path.join(OTLDIR, oldAssetName+'.otl') if os.path.exists(newfilepath): hou.ui.displayMessage("Asset by that name already exists. Cannot rename asset.", title='Asset Name', severity=hou.severityType.Error) elif not amu.canRename(assetDirPath, newfilename): hou.ui.displayMessage("Asset checked out in Maya. Cannot rename asset.", title='Asset Name', severity=hou.severityType.Error) else: node.type().definition().copyToHDAFile(newfilepath, new_name=newfilename, new_menu_name=name) hou.hda.installFile(newfilepath, change_oplibraries_file=True) newnode = hou.node(new_asset_methods.determineHPATH()).createNode(newfilename) node.destroy() hou.hda.uninstallFile(oldlibraryPath, change_oplibraries_file=False) subprocess.check_call( ['rm','-f',oldlibraryPath] ) amu.renameAsset(assetDirPath, newfilename) newNodeDir = os.path.join(os.environ['ASSETS_DIR'], newfilename, 'otl') newStableNode = newfilename + '_otl_stable.otl' newOldStableNode = oldAssetName + '_otl_stable.otl' newDest = os.path.join(newNodeDir, 'stable', newStableNode) newOldDest = os.path.join(newNodeDir, 'stable', newOldStableNode) os.remove(newOldDest) shutil.move(newfilepath,newDest) os.symlink(newDest, newfilepath) else: logname, realname = amu.lockedBy(info[0].encode('utf-8')) whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n' errstr = 'Cannot checkout asset. Locked by: \n\n' + whoLocked hou.ui.displayMessage(errstr, title='Asset Locked', severity=hou.severityType.Error) else: hou.ui.displayMessage("Select EXACTLY one node.")
def checkout(node): """Checks out the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database.""" updateDB() if not isDigitalAsset(node): ui.infoWindow("Not a Digital Asset.") else: if node.type().name() == "geometryTemplate": ui.infoWindow("Cannot checkout geometry template node.") return False libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) info = getFileInfo(filename) if info == None: ui.infoWindow("Add OTL First.") elif not info[2] or (info[2] and info[3].encode("utf-8") == USERNAME): copyToUsrDir(node, filename) lockAsset(node, True) saveOTL(node) node.allowEditingOfContents() lockOTL(filename) ui.infoWindow("Checkout Successful!", wtitle="Success!") else: logname, realname = amu.lockedBy(info[3].encode("utf-8")) whoLocked = "User Name: " + logname + "\nReal Name: " + realname + "\n" errstr = "Cannot checkout asset. Locked by: \n\n" + whoLocked ui.infoWindow(errstr, wtitle="Asset Locked", msev=messageSeverity.Error)
def checkin(node = None): """Checks in the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database, and USERNAME must have the lock.""" updateDB() if node != None: if not isDigitalAsset(node): ui.infoWindow("Not a Digital Asset.") else: libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) info = getFileInfo(filename) if info == None: ui.infoWindow("Add the OTL first") elif info[2]: if not node.isLocked() and info[3] == USERNAME: saveOTL(node) # This save is not strictly necessary since we save again two lines down lockAsset(node, False) saveOTL(node) moveToOtlDir(node, filename) unlockOTL(filename) ui.infoWindow("Checkin Successful!") else: logname, realname = amu.lockedBy(info[3].encode('utf-8')) whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n' errstr = 'Cannot checkin asset. Locked by: \n\n' + whoLocked ui.infoWindow(errstr, wtitle='Asset Locked', msev=messageSeverity.Error) else: ui.infoWindow("Already checked in.") else: #ui.infoWindow("Select EXACTLY one node.") checkinLightingFile()
def checkout(node): """Checks out the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database.""" updateDB() if not isDigitalAsset(node): ui.infoWindow("Not a Digital Asset.") else: if node.type().name() == "geometryTemplate": ui.infoWindow("Cannot checkout geometry template node.") return False libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) info = getFileInfo(filename) if info == None: ui.infoWindow("Add OTL First.") elif not info[2] or (info[2] and info[3].encode('utf-8') == USERNAME): copyToUsrDir(node, filename) lockAsset(node, True) saveOTL(node) node.allowEditingOfContents() lockOTL(filename) ui.infoWindow("Checkout Successful!", wtitle='Success!') else: logname, realname = amu.lockedBy(info[3].encode('utf-8')) whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n' errstr = 'Cannot checkout asset. Locked by: \n\n' + whoLocked ui.infoWindow(errstr, wtitle='Asset Locked', msev=messageSeverity.Error)
def getNodeInfo(node): if isDigitalAsset(node): updateDB() libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) nodeInfo = getFileInfo(filename) message = '' logname, realname = amu.lockedBy(nodeInfo[3].encode('utf-8')) if nodeInfo[2]: message = 'Checked out by '+realname+' ('+logname+')' else: message = 'Not checked out. Last checked in by '+realname+' ('+logname+')' ui.infoWindow(message, wtitle='Node Info')
def getNodeInfo(node): if node != None and isDigitalAsset(node): updateDB() libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) nodeInfo = getFileInfo(filename) message = "" if nodeInfo[2]: logname, realname = amu.lockedBy(nodeInfo[3].encode("utf-8")) message = "Checked out by " + realname + " (" + logname + ")" else: message = "Not checked out." ui.infoWindow(message, wtitle="Node Info")
def deleteAsset(node = None): """Deletes the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database. It may not be already checked out in Houdini or in Maya. """ updateDB() if node != None: if not isDigitalAsset(node): hou.ui.displayMessage("Not a Digital Asset.", title='Non-Asset Node', severity=hou.severityType.Error) return else: if isContainer(node): oldlibraryPath = node.type().definition().libraryFilePath() oldfilename = os.path.basename(oldlibraryPath) oldAssetName = oldfilename.split('.')[0] assetDirPath = os.path.join(ASSETSDIR, oldAssetName) dependents = getAssetDependents(oldAssetName) if dependents: hou.ui.displayMessage('The following assets are depenent on this asset: \n\n'+printList(dependents)+'\nModify these assets first before attempting to delete again!!', title='Can NOT delete!', severity=hou.severityType.Error) return info = getFileInfo(oldfilename) if info[2]: logname, realname = amu.lockedBy(info[3].encode('utf-8')) whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n' errstr = 'Cannot delete asset. Locked by: \n\n' + whoLocked hou.ui.displayMessage(errstr, title='Asset Locked', severity=hou.severityType.Error) return if not amu.canRemove(assetDirPath): hou.ui.displayMessage("Asset currently checked out in Maya. Cannot delete asset.", title='Maya Lock', severity=hou.severityType.Error) return message = "The following paths and files will be deleted:\n" + assetDirPath + "\n" + oldlibraryPath hou.ui.displayMessage(message, title='Asset Deleted', severity=hou.severityType.Error) #TODO remove ui module if ui.passwordWindow('d3l3t3p@ssw0rd', wmessage='Enter the deletion password ...'): node.destroy() hou.hda.uninstallFile(oldlibraryPath, change_oplibraries_file=False) try: amu.removeFolder(assetDirPath) os.remove(oldlibraryPath) except Exception as ex: hou.ui.displayMessage("The following exception occured:\n" + str(ex), title='Exception Occured', severity=hou.severityType.Error) return else: hou.ui.displayMessage("Select EXACTLY one node.") return
def deleteAsset(node = None): """Deletes the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database. It may not be already checked out in Houdini or in Maya. """ if node != None: if not isDigitalAsset(node): hou.ui.displayMessage("Not a Digital Asset.", title='Non-Asset Node', severity=hou.severityType.Error) return else: if isContainer(node): oldlibraryPath = node.type().definition().libraryFilePath() oldfilename = os.path.basename(oldlibraryPath) oldAssetName = oldfilename.split('.')[0] assetDirPath = os.path.join(ASSETSDIR, oldAssetName) dependents = getAssetDependents(oldAssetName) if dependents: hou.ui.displayMessage('The following assets are depenent on this asset: \n\n'+printList(dependents)+'\nModify these assets first before attempting to delete again!!', title='Can NOT delete!', severity=hou.severityType.Error) return nodeDir = os.path.join(os.environ['ASSETS_DIR'], oldAssetName, 'otl') info = amu.getVersionedFolderInfo(nodeDir); print info[0] if not info[0] == "": logname, realname = amu.lockedBy(info[0].encode('utf-8')) whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n' errstr = 'Cannot delete asset. Locked by: \n\n' + whoLocked hou.ui.displayMessage(errstr, title='Asset Locked', severity=hou.severityType.Error) return if not amu.canRemove(assetDirPath): hou.ui.displayMessage("Asset currently checked out in Maya. Cannot delete asset.", title='Maya Lock', severity=hou.severityType.Error) return message = "The following paths and files will be deleted:\n" + assetDirPath + "\n" + oldlibraryPath hou.ui.displayMessage(message, title='Asset Deleted', severity=hou.severityType.Error) if passwordWindow('d3l3t3p@ssw0rd', wmessage='Enter the deletion password ...'): node.destroy() hou.hda.uninstallFile(oldlibraryPath, change_oplibraries_file=False) try: amu.removeFolder(assetDirPath) os.remove(oldlibraryPath) except Exception as ex: hou.ui.displayMessage("The following exception occured:\n" + str(ex), title='Exception Occured', severity=hou.severityType.Error) return else: hou.ui.displayMessage("Select EXACTLY one node.") return
def rename(node = None): """Renames the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database. """ updateDB() if node != None: if not isDigitalAsset(node): ui.infoWindow("Not a Digital Asset.") else: if isContainer(node): oldlibraryPath = node.type().definition().libraryFilePath() oldfilename = os.path.basename(oldlibraryPath) oldAssetName = oldfilename.split('.')[0] assetDirPath = os.path.join(ASSETSDIR, oldAssetName) dependents = getAssetDependents(oldAssetName) if dependents: ui.infoWindow('The following assets are depenent on this asset: \n\n'+printList(dependents)+'\nModify these assets first before attempting to rename again!!', wtitle='Can NOT rename!', msev=messageSeverity.Error) return info = getFileInfo(oldfilename) if not info[2]: if ui.passwordWindow('r3n@m3p@ssw0rd', wmessage='Enter the rename password...'): resp = ui.inputWindow("Enter the New Operator Label", wtitle="Rename OTL") if resp != None and resp.strip() != '': name = formatName(resp) newfilename = name.replace(' ', '_') newfilepath = os.path.join(OTLDIR, newfilename+'.otl') if os.path.exists(newfilepath): ui.infoWindow("Asset by that name already exists. Cannot rename asset.", wtitle='Asset Name', msev=messageSeverity.Error) elif not amu.canRename(assetDirPath, newfilename): ui.infoWindow("Asset checked out in Maya. Cannot rename asset.", wtitle='Asset Name', msev=messageSeverity.Error) else: node.type().definition().copyToHDAFile(newfilepath, new_name=newfilename, new_menu_name=name) hou.hda.installFile(newfilepath, change_oplibraries_file=True) newnode = hou.node(determineHPATH()).createNode(newfilename) node.destroy() hou.hda.uninstallFile(oldlibraryPath, change_oplibraries_file=False) subprocess.check_call( ['rm','-f',oldlibraryPath] ) amu.renameAsset(assetDirPath, newfilename) else: logname, realname = amu.lockedBy(info[3].encode('utf-8')) whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n' errstr = 'Cannot checkout asset. Locked by: \n\n' + whoLocked ui.infoWindow(errstr, wtitle='Asset Locked', msev=messageSeverity.Error) else: ui.infoWindow("Select EXACTLY one node.")
def getInfo(node): if node == None: # code for getting info from the checked out scene file goes here sys.stderr.write('Code for shot info does not yet exist for Houdini!') pass elif isDigitalAsset(node): # code for getting info selected node updateDB() libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) nodeInfo = getFileInfo(filename) message = '' if nodeInfo[2]: logname, realname = amu.lockedBy(nodeInfo[3].encode('utf-8')) message = 'Checked out by '+realname+' ('+logname+')' else: message = 'Not checked out.' ui.infoWindow(message, wtitle='Node Info')
def getInfo(node): if node == None: # code for getting info from the checked out scene file goes here sys.stderr.write("Code for shot info does not yet exist for Houdini!") pass elif isDigitalAsset(node): # code for getting info selected node updateDB() libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) nodeInfo = getFileInfo(filename) message = "" if nodeInfo[2]: logname, realname = amu.lockedBy(nodeInfo[3].encode("utf-8")) message = "Checked out by " + realname + " (" + logname + ")" else: message = "Not checked out." hou.ui.displayMessage(message, title="Node Info")
def checkin(node=None): """Checks in the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database, and USERNAME must have the lock.""" updateDB() if not isDigitalAsset(node): ui.infoWindow("Not a Digital Asset.") else: libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) info = getFileInfo(filename) if info == None: ui.infoWindow("Add the OTL first") elif info[2]: if not node.isLocked() and info[3] == USERNAME: saveOTL(node) # This save is not strictly necessary since we save again two lines down lockAsset(node, False) saveOTL(node) moveToOtlDir(node, filename) unlockOTL(filename) if ( isCameraAsset(node) and ui.infoWindow( "Export Alembic?", wbuttons=("Yes", "No"), wdefault_choice=0, wtitle="Export Alembic" ) == 0 ): writeCamerasToAlembic(node) if ( isSetAsset(node) and ui.infoWindow( "Export Alembic?", wbuttons=("Yes", "No"), wdefault_choice=0, wtitle="Export Alembic" ) == 0 ): writeSetToAlembic(node) ui.infoWindow("Checkin Successful!") else: logname, realname = amu.lockedBy(info[3].encode("utf-8")) whoLocked = "User Name: " + logname + "\nReal Name: " + realname + "\n" errstr = "Cannot checkin asset. Locked by: \n\n" + whoLocked ui.infoWindow(errstr, wtitle="Asset Locked", msev=messageSeverity.Error) else: ui.infoWindow("Already checked in.")
def getInfo(node): if node == None: # code for getting info from the checked out scene file goes here sys.stderr.write('Code for shot info does not yet exist for Houdini!') pass elif isDigitalAsset(node): # code for getting info selected node libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) assetname, ext = os.path.splitext(filename) nodeDir = os.path.join(os.environ['ASSETS_DIR'], assetname, 'otl') nodeInfo = amu.getVersionedFolderInfo(nodeDir) message = '' if nodeInfo[0]: logname, realname = amu.lockedBy(nodeInfo[0].encode('utf-8')) message = 'Checked out by '+realname+' ('+logname+').\n' else: message = 'Not Checked out.\n' message = message+'Last checked in by '+nodeInfo[3] hou.ui.displayMessage(message, title='Node Info')
def getInfo(node, window_title='Node Info'): if node == None: # code for getting info from the checked out scene file goes here sys.stderr.write('Code for shot info does not yet exist for Houdini!') pass elif isDigitalAsset(node): # code for getting info selected node libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) assetname, ext = os.path.splitext(filename) nodeDir = os.path.join(os.environ['ASSETS_DIR'], assetname, 'otl') nodeInfo = amu.getVersionedFolderInfo(nodeDir) message = '' if nodeInfo[0]: logname, realname = amu.lockedBy(nodeInfo[0].encode('utf-8')) message = 'Checked out by ' + realname + ' (' + logname + ').\n' else: message = 'Not Checked out.\n' message = message + 'Last checked in by ' + nodeInfo[3] hou.ui.displayMessage(message, title=window_title)
def checkin(node = None): """Checks in the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database, and USERNAME must have the lock.""" updateDB() if not isDigitalAsset(node): ui.infoWindow("Not a Digital Asset.") else: libraryPath = node.type().definition().libraryFilePath() filename = os.path.basename(libraryPath) info = getFileInfo(filename) if info == None: ui.infoWindow("Add the OTL first") elif info[2]: if not node.isLocked() and info[3] == USERNAME: saveOTL(node) # This save is not strictly necessary since we save again two lines down lockAsset(node, False) saveOTL(node) moveToOtlDir(node, filename) unlockOTL(filename) if isCameraAsset(node) and ui.infoWindow('Export Alembic?' , wbuttons=('Yes','No',) , wdefault_choice=0 , wtitle='Export Alembic') == 0: writeCamerasToAlembic(node) if isSetAsset(node) and ui.infoWindow('Export Alembic?' , wbuttons=('Yes','No',) , wdefault_choice=0 , wtitle='Export Alembic') == 0: writeSetToAlembic(node) ui.infoWindow("Checkin Successful!") else: logname, realname = amu.lockedBy(info[3].encode('utf-8')) whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n' errstr = 'Cannot checkin asset. Locked by: \n\n' + whoLocked ui.infoWindow(errstr, wtitle='Asset Locked', msev=messageSeverity.Error) else: ui.infoWindow("Already checked in.")
def rename(node=None): """Renames the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database. """ updateDB() if node != None: if not isDigitalAsset(node): hou.ui.displayMessage("Not a Digital Asset.") else: if isContainer(node): oldlibraryPath = node.type().definition().libraryFilePath() oldfilename = os.path.basename(oldlibraryPath) oldAssetName = oldfilename.split(".")[0] assetDirPath = os.path.join(ASSETSDIR, oldAssetName) dependents = getAssetDependents(oldAssetName) if dependents: hou.ui.displayMessage( "The following assets are depenent on this asset: \n\n" + printList(dependents) + "\nModify these assets first before attempting to rename again!!", title="Can NOT rename!", severity=hou.severityType.Error, ) return info = getFileInfo(oldfilename) if not info[2]: # TODO: replace ui function if ui.passwordWindow("r3n@m3p@ssw0rd", "Enter the rename password..."): resp = hou.ui.displayMessage("Enter the New Operator Label", title="Rename OTL") if resp != None and resp.strip() != "": name = formatName(resp) newfilename = name.replace(" ", "_") newfilepath = os.path.join(OTLDIR, newfilename + ".otl") if os.path.exists(newfilepath): hou.ui.displayMessage( "Asset by that name already exists. Cannot rename asset.", title="Asset Name", severity=hou.severityType.Error, ) elif not amu.canRename(assetDirPath, newfilename): hou.ui.displayMessage( "Asset checked out in Maya. Cannot rename asset.", title="Asset Name", severity=hou.severityType.Error, ) else: node.type().definition().copyToHDAFile( newfilepath, new_name=newfilename, new_menu_name=name ) hou.hda.installFile(newfilepath, change_oplibraries_file=True) newnode = hou.node(determineHPATH()).createNode(newfilename) node.destroy() hou.hda.uninstallFile(oldlibraryPath, change_oplibraries_file=False) subprocess.check_call(["rm", "-f", oldlibraryPath]) amu.renameAsset(assetDirPath, newfilename) else: logname, realname = amu.lockedBy(info[3].encode("utf-8")) whoLocked = "User Name: " + logname + "\nReal Name: " + realname + "\n" errstr = "Cannot checkout asset. Locked by: \n\n" + whoLocked hou.ui.displayMessage(errstr, title="Asset Locked", severity=hou.severityType.Error) else: hou.ui.displayMessage("Select EXACTLY one node.")
def deleteAsset(node=None): """Deletes the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database. It may not be already checked out in Houdini or in Maya. """ updateDB() if node != None: if not isDigitalAsset(node): ui.infoWindow("Not a Digital Asset.", wtitle="Non-Asset Node", msev=messageSeverity.Error) return else: if isContainer(node): oldlibraryPath = node.type().definition().libraryFilePath() oldfilename = os.path.basename(oldlibraryPath) oldAssetName = oldfilename.split(".")[0] assetDirPath = os.path.join(ASSETSDIR, oldAssetName) dependents = getAssetDependents(oldAssetName) if dependents: ui.infoWindow( "The following assets are depenent on this asset: \n\n" + printList(dependents) + "\nModify these assets first before attempting to delete again!!", wtitle="Can NOT delete!", msev=messageSeverity.Error, ) return info = getFileInfo(oldfilename) if info[2]: logname, realname = amu.lockedBy(info[3].encode("utf-8")) whoLocked = "User Name: " + logname + "\nReal Name: " + realname + "\n" errstr = "Cannot delete asset. Locked by: \n\n" + whoLocked ui.infoWindow(errstr, wtitle="Asset Locked", msev=messageSeverity.Error) return if not amu.canRemove(assetDirPath): ui.infoWindow( "Asset currently checked out in Maya. Cannot delete asset.", wtitle="Maya Lock", msev=messageSeverity.Error, ) return message = "The following paths and files will be deleted:\n" + assetDirPath + "\n" + oldlibraryPath ui.infoWindow(message, wtitle="Asset Deleted", msev=messageSeverity.Message) if ui.passwordWindow("d3l3t3p@ssw0rd", wmessage="Enter the deletion password ..."): node.destroy() hou.hda.uninstallFile(oldlibraryPath, change_oplibraries_file=False) try: amu.removeFolder(assetDirPath) os.remove(oldlibraryPath) except Exception as ex: ui.infoWindow( "The following exception occured:\n" + str(ex), wtitle="Exception Occured", msev=messageSeverity.Error, ) return else: ui.infoWindow("Select EXACTLY one node.") return
def rename(node=None): """Renames the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset. The node must already exist in the database. """ if node != None: if not isDigitalAsset(node): hou.ui.displayMessage("Not a Digital Asset.") else: if isContainer(node): oldlibraryPath = node.type().definition().libraryFilePath() oldfilename = os.path.basename(oldlibraryPath) oldAssetName = oldfilename.split('.')[0] assetDirPath = os.path.join(ASSETSDIR, oldAssetName) dependents = getAssetDependents(oldAssetName) if dependents: hou.ui.displayMessage( 'The following assets are depenent on this asset: \n\n' + printList(dependents) + '\nModify these assets first before attempting to rename again!!', title='Can NOT rename!', severity=hou.severityType.Error) return nodeDir = os.path.join(os.environ['ASSETS_DIR'], oldAssetName, 'otl') info = amu.getVersionedFolderInfo(nodeDir) if info[0] == "": if passwordWindow('r3n@m3p@ssw0rd', 'Enter the rename password...'): resp = hou.ui.readInput("Enter the New Operator Label", title="Rename OTL") if resp != None and resp[1].strip() != '': name = formatName(resp[1]) newfilename = name.replace(' ', '_') newfilepath = os.path.join(OTLDIR, newfilename + '.otl') oldfilepath = os.path.join(OTLDIR, oldAssetName + '.otl') if os.path.exists(newfilepath): hou.ui.displayMessage( "Asset by that name already exists. Cannot rename asset.", title='Asset Name', severity=hou.severityType.Error) elif not amu.canRename(assetDirPath, newfilename): hou.ui.displayMessage( "Asset checked out in Maya. Cannot rename asset.", title='Asset Name', severity=hou.severityType.Error) else: node.type().definition().copyToHDAFile( newfilepath, new_name=newfilename, new_menu_name=name) hou.hda.installFile( newfilepath, change_oplibraries_file=True) newnode = hou.node( new_asset_methods.determineHPATH( )).createNode(newfilename) node.destroy() hou.hda.uninstallFile( oldlibraryPath, change_oplibraries_file=False) subprocess.check_call( ['rm', '-f', oldlibraryPath]) amu.renameAsset(assetDirPath, newfilename) newNodeDir = os.path.join( os.environ['ASSETS_DIR'], newfilename, 'otl') newStableNode = newfilename + '_otl_stable.otl' newOldStableNode = oldAssetName + '_otl_stable.otl' newDest = os.path.join(newNodeDir, 'stable', newStableNode) newOldDest = os.path.join( newNodeDir, 'stable', newOldStableNode) os.remove(newOldDest) shutil.move(newfilepath, newDest) os.symlink(newDest, newfilepath) else: logname, realname = amu.lockedBy(info[0].encode('utf-8')) whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n' errstr = 'Cannot checkout asset. Locked by: \n\n' + whoLocked hou.ui.displayMessage(errstr, title='Asset Locked', severity=hou.severityType.Error) else: hou.ui.displayMessage("Select EXACTLY one node.")