def updateUI(self): """ Disable the OK button if either of the text fields are empty or the job path is invalid. """ enable = True jobPath = os_wrapper.translatePath(self.ui.jobPath_lineEdit.text()) if self.ui.jobName_lineEdit.text() == "": enable = False if self.ui.jobPath_lineEdit.text() == "": enable = False if not os_wrapper.checkIllegalChars(jobPath): verbose.illegalCharacters(jobPath) enable = False self.ui.buttonBox.button( QtWidgets.QDialogButtonBox.Ok).setEnabled(enable)
def browseDir(self): """ Open a dialog from which to select a folder. """ startingDir = os_wrapper.translatePath(self.ui.jobPath_lineEdit.text()) if os.path.isdir(startingDir): dialogHome = startingDir else: dialogHome = os.environ['IC_JOBSROOT'] # Append slash to path if it's a Windows drive letter, otherwise file # dialog won't open the correct location if dialogHome.endswith(':'): dialogHome += '/' #dialogPath = QtWidgets.QFileDialog.getExistingDirectory(self, self.tr('Directory'), dialogHome, QtWidgets.QFileDialog.DontResolveSymlinks | QtWidgets.QFileDialog.ShowDirsOnly) ##dialog = QtWidgets.QFileDialog(self) dialogPath = self.folderDialog(dialogHome) if dialogPath: # if dialog.exec_(): # dialogPath = dialog.getExistingDirectory(self, self.tr('Directory'), dialogHome, QtWidgets.QFileDialog.DontResolveSymlinks | QtWidgets.QFileDialog.ShowDirsOnly) if os_wrapper.checkIllegalChars(dialogPath): #, r'[^\w\.-]'): jobPath = os_wrapper.relativePath(dialogPath, 'IC_JOBSROOT') self.ui.jobPath_lineEdit.setText(jobPath) # Only autofill job name field it it's empty if not self.ui.jobName_lineEdit.text(): try: # if os.environ['IC_JOBSROOT'] in os_wrapper.absolutePath(jobPath): # jobName = jobPath.split('/')[1] # else: # jobName = jobPath.split('/')[-1] jobName = os.path.basename(jobPath) self.ui.jobName_lineEdit.setText(jobName) except IndexError: pass else: verbose.illegalCharacters(dialogPath) # Warning dialog dialogTitle = "Path contains illegal characters" dialogMsg = "The path \"%s\" contains illegal characters. File and folder names must be formed of alphanumeric characters, underscores, hyphens and dots only." % dialogPath dialog = prompt.dialog() dialog.display(dialogMsg, dialogTitle, conf=True)
def publish(pblTo, slShot, nodeType, textures, pblNotes): # Get selection objLs = mc.ls(sl=True) # Check item count if not pblChk.itemCount(objLs): return # Define main variables assetType = '%s_node' % nodeType subsetName = mc.nodeType(objLs[0]) prefix = '' convention = objLs[0] suffix = '_node' fileType = 'mayaAscii' extension = 'ma' # Check for illegal characters cleanObj = os_wrapper.sanitize(convention) if cleanObj != convention: verbose.illegalCharacters(convention) return # Check if asset to publish is a set if mc.nodeType(convention) == 'objectSet': verbose.noSetsPbl() return # Check if asset to publish is an icSet if mayaOps.chkIcDataSet(convention): verbose.noICSetsPbl() return # Check if asset to publish is referenced if mc.referenceQuery(convention, inr=True): verbose.noRefPbl() return # Process asset publish options assetPblName, assetDir, pblDir = pblOptsPrc.prc(pblTo, subsetName, assetType, prefix, convention, suffix) # Add shot name to assetPblName if asset is being publish to a shot # Determining publish env var for relative directory if pblTo != os.environ['IC_JOBPUBLISHDIR']: assetPblName += '_%s' % slShot # Version control version = '%s' % vCtrl.version(pblDir) # if approved: # version += '_apv' # Confirmation dialog dialogTitle = 'Publishing %s' % convention dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\nNotes:\t%s' % ( assetPblName, version, subsetName, pblNotes) dialog = prompt.dialog() if not dialog.display(dialogMsg, dialogTitle): return # Publishing try: verbose.pblFeed(begin=True) # Create publish directories pblDir = os_wrapper.createDir(os.path.join(pblDir, version)) if textures: os_wrapper.createDir(os.path.join(pblDir, 'tx')) # Create in-progress tmp file inProgress.start(pblDir) # Store asset metadata in file src = mayaOps.getScene() icPblData.writeData(pblDir, assetPblName, convention, assetType, extension, version, pblNotes, src) # Maya operations mayaOps.deleteICDataSet(objLs) if textures: # Copy textures to publish directory (use hardlink instead?) txFullPath = os.path.join(pblDir, 'tx') # txRelPath = txFullPath.replace(os.path.expandvars('$IC_JOBPATH'), '$IC_JOBPATH') # txPaths = (txFullPath, txRelPath) # Returns a dict for fileNodes and oldTxPaths if updateMaya = True oldTxPaths = mayaOps.updateTextures(txFullPath, txObjLs=objLs, updateMaya=True) # File operations pathToPblAsset = os.path.join(pblDir, '%s.%s' % (assetPblName, extension)) verbose.pblFeed(msg=assetPblName) mayaOps.exportSelection(pathToPblAsset, fileType) # Write Nuke file if ic and file node type if nodeType == 'ic': if subsetName == 'file': fileTypeLs = ('.jpg', '.jpeg', '.hdr', '.exr', '.tif', '.tiff', '.tga', '.png') fileLs = os.listdir(os.path.join(pblDir, 'tx')) for file_ in fileLs: if file_.endswith(fileTypeLs, -4): fileName = file_ mayaOps.nkFileNodeExport(objLs, nodeType, fileName, pblDir, pblDir, assetPblName, version) # Reverts the texture paths if textures and oldTxPaths: mayaOps.relinkTextures(oldTxPaths) # Delete in-progress tmp file inProgress.end(pblDir) # Published asset check pblResult = pblChk.success(pathToPblAsset) verbose.pblFeed(end=True) except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) pathToPblAsset = '' os_wrapper.remove(pblDir) pblResult = pblChk.success(pathToPblAsset) pblResult += verbose.pblRollback() # Show publish result dialog dialogTitle = 'Publish Report' dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\n\n%s' % ( assetPblName, version, subsetName, pblResult) dialog = prompt.dialog() dialog.display(dialogMsg, dialogTitle, conf=True)
def publish(pblTo, slShot, subtype, textures, pblNotes): # Get selection objLs = mc.ls(sl=True) # Check item count if not pblChk.itemCount(objLs): return # Define main variables geoType = 'abc' subsetName = subtype assetType = 'ic_pointCloud' prefix = '' convention = objLs[0] suffix = '_pointCloud' ma_fileType = 'mayaBinary' extension = geoType # Check for illegal characters cleanObj = os_wrapper.sanitize(convention) if cleanObj != convention: verbose.illegalCharacters(convention) return # Check if item is particle objSh = mc.listRelatives(objLs[0])[0] objType = mayaOps.nodetypeCheck(objSh) if objType not in ('particle', 'nParticle'): verbose.pointCloudParticle() return # Get all dependents allObjLs = mc.listRelatives(convention, ad=True, f=True, typ='transform') if allObjLs: allObjLs.append(convention) else: allObjLs = [convention] # Check if asset to publish is a set if mc.nodeType(convention) == 'objectSet': verbose.noSetsPbl() return # Check if asset to publish is an icSet if mayaOps.chkIcDataSet(convention): verbose.noICSetsPbl() return # Check if asset to publish is referenced for allObj in allObjLs: if mc.referenceQuery(allObj, inr=True): verbose.noRefPbl() return # Process asset publish options assetPblName, assetDir, pblDir = pblOptsPrc.prc(pblTo, subsetName, assetType, prefix, convention, suffix) # Add shot name to assetPblName if asset is being publish to a shot # Determining publish env var for relative directory if pblTo != os.environ['IC_JOBPUBLISHDIR']: assetPblName += '_%s' % slShot pblRelDir = '$IC_SHOTPUBLISHDIR' else: pblRelDir = '$IC_JOBPUBLISHDIR' # Version control version = '%s' % vCtrl.version(pblDir) # if approved: # version += '_apv' # Confirmation dialog dialogTitle = 'Publishing %s' % convention dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\nNotes:\t%s' % ( assetPblName, version, subsetName, pblNotes) dialog = prompt.dialog() if not dialog.display(dialogMsg, dialogTitle): return # Publishing try: verbose.pblFeed(begin=True) # Create publish directories pblDir = os_wrapper.createDir(os.path.join(pblDir, version)) if textures: os_wrapper.createDir(os.path.join(pblDir, 'tx')) # Create in-progress tmp file inProgress.start(pblDir) # Store asset metadata in file src = mayaOps.getScene() icPblData.writeData(pblDir, assetPblName, convention, assetType, extension, version, pblNotes, src) # Maya operations if textures: # Copy textures to publish directory (use hardlink instead?) txFullPath = os.path.join(pblDir, 'tx') # txRelPath = txFullPath.replace(pblTo, pblRelDir) # txPaths = (txFullPath, txRelPath) # Returns a dict for fileNodes and oldTxPaths if updateMaya = True oldTxPaths = mayaOps.updateTextures(txFullPath, txObjLs=allObjLs, updateMaya=True) # Get transform data, write to file and zero obj out objTrs = mayaOps.getTransforms(convention) if objTrs: objT, objR, objS = objTrs else: raise RuntimeError(verbose.noGetTranforms()) trsDataFile = open('%s/trsData.py' % (pblDir), 'w') trsDataFile.write('t=%s\nr=%s\ns=%s' % (objT, objR, objS)) trsDataFile.close() mayaOps.applyTransforms(convention, [0, 0, 0], [0, 0, 0], [1, 1, 1]) # Take snapshot mayaOps.snapShot(pblDir, isolate=True, fit=True) # File operations pathToPblAsset = os.path.join(pblDir, '%s.%s' % (assetPblName, extension)) verbose.pblFeed(msg=assetPblName) mayaOps.exportSelection(pathToPblAsset, ma_fileType) mayaOps.exportGeo(objLs, geoType, pathToPblAsset) # Re-apply original transforms to object mayaOps.applyTransforms(convention, objT, objR, objS) # Reverts the texture paths if textures and oldTxPaths: mayaOps.relinkTextures(oldTxPaths) # Delete in-progress tmp file inProgress.end(pblDir) # Published asset check pblResult = pblChk.success(pathToPblAsset) verbose.pblFeed(end=True) except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) pathToPblAsset = '' os_wrapper.remove(pblDir) pblResult = pblChk.success(pathToPblAsset) pblResult += verbose.pblRollback() # Show publish result dialog dialogTitle = 'Publish Report' dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\n\n%s' % ( assetPblName, version, subsetName, pblResult) dialog = prompt.dialog() dialog.display(dialogMsg, dialogTitle, conf=True)
def publish(pblTo, slShot, pblNotes): # Get selection objLs = mc.ls(sl=True) # Check item count if not pblChk.itemCount(objLs): return # Define main variables shot_ = os.environ['IC_SHOT'] assetType = 'ma_anim' subsetName = '' prefix = '' convention = objLs[0] suffix = '_anim' fileType = 'atomExport' extension = 'atom' # Check for illegal characters cleanObj = os_wrapper.sanitize(convention) if cleanObj != convention: verbose.illegalCharacters(convention) return # Get all dependents allObjLs = mc.listRelatives(convention, ad=True, f=True) # Add original selection to allObj if no dependents are found if allObjLs: allObjLs.append(convention) else: allObjLs = [convention] # Check if asset to publish is a set if mc.nodeType(convention) == 'objectSet': verbose.noSetsPbl() return # Check if asset to publish is an icSet if mayaOps.chkIcDataSet(convention): verbose.noICSetsPbl() return # Check if asset to publish is referenced for allObj in allObjLs: if mc.referenceQuery(allObj, inr=True): verbose.noRefPbl() return # Check if selected asset is a published asset and matches the asset name try: ICSetConn = mc.listConnections('%s.icARefTag' % convention) if not ICSetConn[0].startswith('ICSet'): raise RuntimeError('ICSet') except: verbose.pblAssetReq() return # Process asset publish options assetPblName, assetDir, pblDir = pblOptsPrc.prc(pblTo, subsetName, assetType, prefix, convention, suffix) # Add shot name to assetPblName if asset is being publish to a shot # Determining publish env var for relative directory if pblTo != os.environ['IC_JOBPUBLISHDIR']: assetPblName += '_%s' % slShot # Version control version = '%s' % vCtrl.version(pblDir) # if approved: # version += '_apv' # Confirmation dialog dialogTitle = 'Publishing %s' % convention dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\nNotes:\t%s' % ( assetPblName, version, subsetName, pblNotes) dialog = prompt.dialog() if not dialog.display(dialogMsg, dialogTitle): return # Publishing try: verbose.pblFeed(begin=True) # Create publish directories pblDir = os_wrapper.createDir(os.path.join(pblDir, version)) # Create in-progress tmp file inProgress.start(pblDir) # Store asset metadata in file src = mayaOps.getScene() requires = mc.getAttr('%s.icRefTag' % ICSetConn[0]) compatible = '%s_%s' % (requires, mc.getAttr('ICSet_%s.icVersion' % requires)) icPblData.writeData(pblDir, assetPblName, convention, assetType, extension, version, pblNotes, src, requires, compatible) # Maya operations pathToPblAsset = os.path.join(pblDir, '%s.%s' % (assetPblName, extension)) verbose.pblFeed(msg=assetPblName) mayaOps.exportAnimation(pathToPblAsset, pblDir, objLs) # os_wrapper.setPermissions(os.path.join(pblDir, '*')) # Delete in-progress tmp file inProgress.end(pblDir) # Published asset check pblResult = pblChk.success(pathToPblAsset) verbose.pblFeed(end=True) except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) pathToPblAsset = '' os_wrapper.remove(pblDir) pblResult = pblChk.success(pathToPblAsset) pblResult += verbose.pblRollback() # Show publish result dialog dialogTitle = 'Publish Report' dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\n\n%s' % ( assetPblName, version, subsetName, pblResult) dialog = prompt.dialog() dialog.display(dialogMsg, dialogTitle, conf=True)
def publish(pblTo, slShot, subtype, textures, pblNotes): # Get selection objLs = mc.ls(sl=True) # Check item count if not pblChk.itemCount(objLs): return # Define main variables assetType = 'ma_model' subsetName = subtype prefix = '' convention = objLs[0] suffix = '_%s_model' % subtype fileType = 'mayaBinary' extension = 'mb' autoLods = False # Check for illegal characters cleanObj = os_wrapper.sanitize(convention) if cleanObj != convention: verbose.illegalCharacters(convention) return # Get all dependents. Creates a group for LODs with just dependents allObjLs = mc.listRelatives(convention, ad=True, f=True, typ='transform') objLodLs = allObjLs # Add original selection to allObj if no dependents are found if allObjLs: allObjLs.append(convention) else: allObjLs = [convention] objLodLs = [convention] # Check if asset to publish is a set if mc.nodeType(convention) == 'objectSet': verbose.noSetsPbl() return # Check if asset to publish is an icSet if mayaOps.chkIcDataSet(convention): verbose.noICSetsPbl() return # Check if asset to publish is referenced for allObj in allObjLs: if mc.referenceQuery(allObj, inr=True): verbose.noRefPbl() return # Process asset publish options assetPblName, assetDir, pblDir = pblOptsPrc.prc(pblTo, subsetName, assetType, prefix, convention, suffix) # Add shot name to assetPblName if asset is being publish to a shot # Determining publish env var for relative directory if pblTo != os.environ['IC_JOBPUBLISHDIR']: assetPblName += '_%s' % slShot # Version control version = '%s' % vCtrl.version(pblDir) # if approved: # version += '_apv' # Confirmation dialog dialogTitle = 'Publishing %s' % convention dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\nNotes:\t%s' % (assetPblName, version, subsetName, pblNotes) dialog = prompt.dialog() if not dialog.display(dialogMsg, dialogTitle): return # Publishing try: verbose.pblFeed(begin=True) # Create publish directories pblDir = os_wrapper.createDir(os.path.join(pblDir, version)) if textures: os_wrapper.createDir(os.path.join(pblDir, 'tx')) # Create in-progress tmp file inProgress.start(pblDir) # Store asset metadata in file src = mayaOps.getScene() #for i in ('pblDir', 'assetPblName', 'convention', 'assetType', 'extension', 'version', 'src', 'pblNotes') # publishVars[i] = locals()[i] #icPblData.writeData(publishVars) icPblData.writeData(pblDir, assetPblName, convention, assetType, extension, version, pblNotes, src) # Publish operations mayaOps.deleteICDataSet(allObjLs) if textures: # Copy textures to publish directory (use hardlink instead?) txFullPath = os.path.join(pblDir, 'tx') # txRelPath = txFullPath.replace(os.path.expandvars('$IC_JOBPATH'), '$IC_JOBPATH') # txPaths = (txFullPath, txRelPath) # Returns a dict for fileNodes and oldTxPaths if updateMaya = True oldTxPaths = mayaOps.updateTextures(txFullPath, txObjLs=allObjLs, updateMaya=True) # Take snapshot mayaOps.snapShot(pblDir, isolate=True, fit=True) # File operations pathToPblAsset = os.path.join(pblDir, '%s.%s' % (assetPblName, extension)) verbose.pblFeed(msg=assetPblName) mayaOps.exportSelection(pathToPblAsset, fileType) # Reverts the texture paths if textures and oldTxPaths: mayaOps.relinkTextures(oldTxPaths) # Delete in-progress tmp file inProgress.end(pblDir) # Published asset check pblResult = pblChk.success(pathToPblAsset) verbose.pblFeed(end=True) except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) pathToPblAsset = '' os_wrapper.remove(pblDir) # was commented out? pblResult = pblChk.success(pathToPblAsset) pblResult += verbose.pblRollback() # Show publish result dialog dialogTitle = 'Publish Report' dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\n\n%s' % (assetPblName, version, subsetName, pblResult) dialog = prompt.dialog() dialog.display(dialogMsg, dialogTitle, conf=True)
def publish(pblTo, slShot, subtype, pblNotes): # Get selection objLs = mc.ls(sl=True) # Check item count if not pblChk.itemCount(objLs): return # Define main variables assetType = 'ma_geoCache' subsetName = subtype prefix = '' convention = objLs[0] suffix = '_%s_geoCache' % subtype if subtype == 'vrmesh': fileType = 'vrmesh' extension = 'vrmesh' elif subtype == 'realflow': fileType = 'sd' extension = 'sd' else: fileType = 'abc' extension = 'abc' # Check for illegal characters cleanObj = os_wrapper.sanitize(convention) if cleanObj != convention: verbose.illegalCharacters(convention) return # Get all dependents allObjLs = mc.listRelatives(convention, ad=True, f=True, typ='transform') if allObjLs: allObjLs.append(convention) else: allObjLs = [convention] # Check if asset to publish is a set if mc.nodeType(convention) == 'objectSet': verbose.noSetsPbl() return # Check if asset to publish is an icSet if mayaOps.chkIcDataSet(convention): verbose.noICSetsPbl() return # Check if asset to publish is referenced for allObj in allObjLs: if mc.referenceQuery(allObj, inr=True): verbose.noRefPbl() return # Process asset publish options assetPblName, assetDir, pblDir = pblOptsPrc.prc(pblTo, subsetName, assetType, prefix, convention, suffix) # Add shot name to assetPblName if asset is being publish to a shot # Determining publish env var for relative directory if pblTo != os.environ['IC_JOBPUBLISHDIR']: assetPblName += '_%s' % slShot # Version control version = '%s' % vCtrl.version(pblDir) # if approved: # version += '_apv' # Confirmation dialog dialogTitle = 'Publishing %s' % convention dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\nNotes:\t%s' % (assetPblName, version, subsetName, pblNotes) dialog = prompt.dialog() if not dialog.display(dialogMsg, dialogTitle): return # Publishing try: verbose.pblFeed(begin=True) # Create publish directories pblDir = os_wrapper.createDir(os.path.join(pblDir, version)) # Create in-progress tmp file inProgress.start(pblDir) # Store asset metadata in file src = mayaOps.getScene() icPblData.writeData(pblDir, assetPblName, convention, assetType, extension, version, pblNotes, src) # Maya operations mayaOps.deleteICDataSet(allObjLs) # Take snapshot mayaOps.snapShot(pblDir, isolate=True, fit=True) # File operations pathToPblAsset = os.path.join(pblDir, '%s.%s' % (assetPblName, extension)) verbose.pblFeed(msg=assetPblName) mayaOps.exportGeo(objLs, fileType, pathToPblAsset) # Delete in-progress tmp file inProgress.end(pblDir) # Published asset check pblResult = pblChk.success(pathToPblAsset) verbose.pblFeed(end=True) except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) pathToPblAsset = '' os_wrapper.remove(pblDir) pblResult = pblChk.success(pathToPblAsset) pblResult += verbose.pblRollback() # Show publish result dialog dialogTitle = 'Publish Report' dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\n\n%s' % (assetPblName, version, subsetName, pblResult) dialog = prompt.dialog() dialog.display(dialogMsg, dialogTitle, conf=True)
def publish(pblTo, slShot, subtype, pblName, pblNotes): # Get selection nodeLs = nuke.selectedNodes() # Check item count if subtype == 'node': if not pblChk.itemCount(nodeLs): return else: if not pblChk.itemCount(nodeLs, mult=True): return # Define main variables shot_ = '' assetType = 'nk_%s' % subtype subsetName = '' prefix = '' convention = pblName suffix = '_%s' % subtype fileType = 'nk' extension = 'nk' # Check for illegal characters cleanObj = os_wrapper.sanitize(convention) if cleanObj != convention: verbose.illegalCharacters(convention) return # Process asset publish options assetPblName, assetDir, pblDir = pblOptsPrc.prc(pblTo, subsetName, assetType, prefix, convention, suffix) # Add shot name to assetPblName if asset is being publish to a shot if pblTo != os.environ['IC_JOBPUBLISHDIR']: assetPblName += '_%s' % slShot # Version control version = '%s' % vCtrl.version(pblDir) # if approved: # version += '_apv' # Confirmation dialog dialogTitle = 'Publishing %s' % convention dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\nNotes:\t%s' % ( assetPblName, version, subsetName, pblNotes) dialog = prompt.dialog() if not dialog.display(dialogMsg, dialogTitle): return # Publishing try: verbose.pblFeed(begin=True) # Create publish directories pblDir = os_wrapper.createDir(os.path.join(pblDir, version)) # Create in-progress tmp file inProgress.start(pblDir) # Store asset metadata in file src = nuke.root().name() #nukeOps.getScriptName() icPblData.writeData(pblDir, assetPblName, assetPblName, assetType, extension, version, pblNotes, src) # Nuke operations icSet = nukeOps.createBackdrop(assetPblName, nodeLs) icSet['selected'].setValue(True) # File operations pathToPblAsset = os.path.join(pblDir, '%s.%s' % (assetPblName, extension)) verbose.pblFeed(msg=assetPblName) nukeOps.exportSelection(pathToPblAsset) nuke.delete(icSet) # Take snapshot nukeOps.viewerSnapshot(pblDir) # Delete in-progress tmp file inProgress.end(pblDir) # Published asset check pblResult = pblChk.success(pathToPblAsset) verbose.pblFeed(end=True) except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) pathToPblAsset = '' os_wrapper.remove(pblDir) pblResult = pblChk.success(pathToPblAsset) pblResult += verbose.pblRollback() # Show publish result dialog dialogTitle = 'Publish Report' dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\n\n%s' % ( assetPblName, version, subsetName, pblResult) dialog = prompt.dialog() dialog.display(dialogMsg, dialogTitle, conf=True)
def publish(pblTo, slShot, scnName, subtype, textures, pblNotes): # Define main variables assetType = 'ma_scene' subsetName = subtype prefix = '' convention = scnName suffix = '_scene' fileType = 'mayaAscii' extension = 'ma' # Check for illegal characters cleanObj = os_wrapper.sanitize(convention) if cleanObj != convention: verbose.illegalCharacters(convention) return # Get all dependents allObjLs = mc.ls(tr=True) # Remove Maya's default cameras from list defaultCamLs = ['front', 'persp', 'side', 'top'] for defaultCam in defaultCamLs: allObjLs.remove(defaultCam) # Check if asset to publish is referenced for allObj in allObjLs: if mc.referenceQuery(allObj, inr=True): verbose.noRefPbl() return # Process asset publish options assetPblName, assetDir, pblDir = pblOptsPrc.prc(pblTo, subsetName, assetType, prefix, convention, suffix) # Add shot name to assetPblName if asset is being publish to a shot # Determining publish env var for relative directory if pblTo != os.environ['IC_JOBPUBLISHDIR']: assetPblName += '_%s' % slShot # Version control version = '%s' % vCtrl.version(pblDir) # if approved: # version += '_apv' # Confirmation dialog dialogTitle = 'Publishing %s' % convention dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\nNotes:\t%s' % (assetPblName, version, subsetName, pblNotes) dialog = prompt.dialog() if not dialog.display(dialogMsg, dialogTitle): return # Publishing try: verbose.pblFeed(begin=True) # Create publish directories pblDir = os_wrapper.createDir(os.path.join(pblDir, version)) if textures: os_wrapper.createDir(os.path.join(pblDir, 'tx')) # Create in-progress tmp file inProgress.start(pblDir) # Store asset metadata in file src = mayaOps.getScene() icPblData.writeData(pblDir, assetPblName, convention, assetType, extension, version, pblNotes, src) # Publish operations try: mc.select('ICSet_*', ne=True, r=True) icSetLs = mc.ls(sl=True) for icSet in icSetLs: mc.delete(icSet) except: pass if textures: # Copy textures to publish directory (use hardlink instead?) txFullPath = os.path.join(pblDir, 'tx') # txRelPath = txFullPath.replace(os.path.expandvars('$IC_JOBPATH'), '$IC_JOBPATH') # txPaths = (txFullPath, txRelPath) # Returns a dict for fileNodes and oldTxPaths if updateMaya = True oldTxPaths = mayaOps.updateTextures(txFullPath, updateMaya=True) # Take snapshot mayaOps.snapShot(pblDir, isolate=False, fit=False) # File operations pathToPblAsset = os.path.join(pblDir, '%s.%s' % (assetPblName, extension)) verbose.pblFeed(msg=assetPblName) activeScene = mayaOps.getScene() mayaOps.redirectScene(pathToPblAsset) mayaOps.saveFile(fileType, updateRecentFiles=False) # Reverts the texture paths if textures and oldTxPaths: mayaOps.relinkTextures(oldTxPaths) mayaOps.redirectScene(activeScene) # Delete in-progress tmp file inProgress.end(pblDir) # Published asset check pblResult = pblChk.success(pathToPblAsset) verbose.pblFeed(end=True) except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) pathToPblAsset = '' os_wrapper.remove(pblDir) pblResult = pblChk.success(pathToPblAsset) pblResult += verbose.pblRollback() # Show publish result dialog dialogTitle = 'Publish Report' dialogMsg = 'Asset:\t%s\n\nVersion:\t%s\n\nSubset:\t%s\n\n\n%s' % (assetPblName, version, subsetName, pblResult) dialog = prompt.dialog() dialog.display(dialogMsg, dialogTitle, conf=True)