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 show_node_info(self):
     asset_name = str(self.current_item.text())
     if self.model_radio.isChecked():
         filePath = os.path.join(os.environ['ASSETS_DIR'], asset_name,
                                 'model')
     elif self.rig_radio.isChecked():
         filePath = os.path.join(os.environ['ASSETS_DIR'], asset_name,
                                 'rig')
     elif self.animation_radio.isChecked():
         filePath = os.path.join(os.environ['SHOTS_DIR'], asset_name,
                                 'animation')
     node_info = amu.getVersionedFolderInfo(filePath)
     checkout_str = node_info[0]
     if (checkout_str == ''):
         checkout_str = 'Not checked out. '
     else:
         checkout_str = 'Checked out by ' + node_info[0] + '. '
     checkin_str = 'Last checked in by ' + node_info[
         1] + ' on ' + node_info[2]
     cmd.confirmDialog(title=asset_name + " Info",
                       message=checkout_str + checkin_str,
                       button=['Ok'],
                       defaultButton='Ok',
                       cancelButton='Ok',
                       dismissString='Ok')
	def show_node_info(self):
		filePath = self.get_asset_path()
		node_info = amu.getVersionedFolderInfo(filePath)
		checkout_str = node_info[0]
		self.unlock_button.setEnabled(checkout_str != '')
		if (checkout_str == ''):
			checkout_str = '<font color="#6EFF81">Not checked out.</font>'
		else:
			checkout_str = '<font color="#FF6E6E">Checked out by '+node_info[0]+'.</font>'
		checkin_str = '<br/>Last checked in by '+node_info[1]+' on '+node_info[2]
		self.asset_info_label.setText(checkout_str+checkin_str)
Exemple #4
0
	def show_node_info(self):
		filePath = self.get_asset_path()
		node_info = amu.getVersionedFolderInfo(filePath)
		checkout_str = node_info[0]
		self.unlock_button.setEnabled(checkout_str != '')
		if (checkout_str == ''):
			checkout_str = '<font color="#6EFF81">Not checked out.</font>'
		else:
			checkout_str = '<font color="#FF6E6E">Checked out by '+node_info[0]+'.</font>'
		#checkin_str = '<br/>Last checked in by '+node_info[1]+' on '+node_info[2]
		checkin_str = '<br/>Last checkin: ' + node_info[3]
		self.asset_info_label.setText(checkout_str+checkin_str)
 def show_node_info(self):
     filePath = self.get_asset_path()
     node_info = amu.getVersionedFolderInfo(filePath)
     checkout_str = node_info[0]
     self.rename_button.setEnabled(checkout_str == '' and not self.context.clone_state)
     self.delete_button.setEnabled(checkout_str == '' and not self.context.clone_state)
     if (checkout_str == ''):
         checkout_str = '<font color="#6EFF81">Not checked out.</font>'
     else:
         checkout_str = '<font color="#FF6E6E">Checked out by '+node_info[0]+'.</font>'
     #checkin_str = '<br/>Last checked in by '+node_info[1]+' on '+node_info[2]
     checkin_str = '<br/>Last checkin: ' + node_info[3]
     self.asset_info_label.setText(checkout_str+checkin_str)
 def _getDescription(self):
     description = ''
     try:
         folderInfo = amu.getVersionedFolderInfo(self.workingDirectory)
         if self.isLocked():
             description += 'Last check out:\n\t' + folderInfo[0] + '\n'
         description += 'Last check in:\n\t' + folderInfo[1] + ' on ' + folderInfo[2] + '\n'
         if folderInfo[3] != '':
             description += "Last Comment:" 
             description += '\n\t"' + folderInfo[3] + '"' + '\n'
     except Exception as e:
         description = str(e)
     return description
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
Exemple #8
0
 def _getDescription(self):
     description = ''
     try:
         folderInfo = amu.getVersionedFolderInfo(self.workingDirectory)
         if self.isLocked():
             description += 'Last check out:\n\t' + folderInfo[0] + '\n'
         description += 'Last check in:\n\t' + folderInfo[
             1] + ' on ' + folderInfo[2] + '\n'
         if folderInfo[3] != '':
             description += "Last Comment:"
             description += '\n\t"' + folderInfo[3] + '"' + '\n'
     except Exception as e:
         description = str(e)
     return description
Exemple #9
0
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 show_node_info(self):
		asset_name = str(self.current_item.text())
		if self.model_radio.isChecked():
			filePath = os.path.join(os.environ['ASSETS_DIR'], asset_name, 'model')
		elif self.rig_radio.isChecked():
			filePath = os.path.join(os.environ['ASSETS_DIR'], asset_name, 'rig')
		elif self.animation_radio.isChecked():
			filePath = os.path.join(os.environ['SHOTS_DIR'], asset_name, 'animation')
		node_info = amu.getVersionedFolderInfo(filePath)
		checkout_str = node_info[0]
		if(checkout_str ==''):
			checkout_str = 'Not checked out. '
		else:
			checkout_str = 'Checked out by '+node_info[0]+'. '
		checkin_str = 'Last checked in by '+node_info[1]+' on '+node_info[2]
		
		print 'should clear label'
		self.asset_info_label.setText(checkout_str+checkin_str)
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')
Exemple #12
0
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 show_node_info(self):
		asset_name = str(self.current_item.text())
		if self.model_radio.isChecked():
			filePath = os.path.join(os.environ['ASSETS_DIR'], asset_name, 'model')
		elif self.rig_radio.isChecked():
			filePath = os.path.join(os.environ['ASSETS_DIR'], asset_name, 'rig')
		elif self.animation_radio.isChecked():
			filePath = os.path.join(os.environ['SHOTS_DIR'], asset_name, 'animation')
		node_info = amu.getVersionedFolderInfo(filePath)
		checkout_str = node_info[0]
		if(checkout_str ==''):
			checkout_str = 'Not checked out. '
		else:
			checkout_str = 'Checked out by '+node_info[0]+'. '
		checkin_str = 'Last checked in by '+node_info[1]+' on '+node_info[2]
		cmd.confirmDialog(  title          = asset_name+" Info"
                                   , message       = checkout_str+checkin_str
                                   , button        = ['Ok']
                                   , defaultButton = 'Ok'
                                   , cancelButton  = 'Ok'
                                   , dismissString = 'Ok')
Exemple #14
0
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.")