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 deleteAsset(): """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() node = getSelectedNode() 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) info = getFileInfo(oldfilename) if not info[2]: ok, resp = hou.ui.readMultiInput("Enter the deletion password...", input_labels=('Password:'******'OK', 'Cancel'), title="Delete Password") resp = resp[0] if ok == 0 and resp == 'd3l3t3p@ssw0rd': name = formatName(resp) 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 else: node.destroy() hou.hda.uninstallFile(oldlibraryPath, change_oplibraries_file=False) try: amu.removeFolder(assetDirPath) os.remove(oldlibraryPath) message = "The following paths and files were deleted:\n" + assetDirPath + "\n" + oldlibraryPath hou.ui.displayMessage(message, title='Asset Deleted', severity=hou.severityType.Message) 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(lockedBy(info[3].encode('utf-8')), title='Asset Locked', severity=hou.severityType.Error) return else: hou.ui.displayMessage("Select EXACTLY one node.") return
def delete(self): print 'The delete function is not complete yet!' if not (self.current_item is None): currentlySelected = self.current_item.text(); print 'currentlySelected:' + currentlySelected; password = cmd.promptDialog( title='Delete password check', message='Enter password:'******'OK','Cancel'], defaultButton='OK', dismissString='Cancel', sf = False); if password == 'OK': if (cmd.promptDialog(query=True, text=True) == 'd3l3t3p@ssw0rd'): newMessage = str('Are you sure you want to delete <' + currentlySelected + '> ?'); confirm = cmd.confirmDialog( title='Confirm delete', message=newMessage, button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if (confirm == 'Yes'): currentlySelected = self.current_item.text(); print 'currentlySelected:' + currentlySelected; dirPath = ''; if self.context_tabs.currentIndex() == 1: dirPath = amu.getProductionDir() + '/previs/' + currentlySelected; else: dirPath = amu.getProductionDir() + '/shots/' + currentlySelected; amu.removeFolder(str(dirPath)); # refresh context tempContext = self.contexts[self.context_tabs.currentIndex()]; tempContext.take_item(tempContext.tree.currentRow()); else: newMessage = str('Wrong password. Did not delete shot <' + currentlySelected + '>'); cmd.confirmDialog( title='Cancelled delete', message=newMessage, button=['Yes'], defaultButton='Yes', cancelButton='Yes', dismissString='Yes')
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