コード例 #1
0
ファイル: gpsNodes.py プロジェクト: all-in-one-of/icarus
def w_create_dir():
    """ Automatically create write node directory.
	"""
    path = os.path.dirname(nuke.filename(nuke.thisNode()))
    if not os.path.isdir(path):
        os_wrapper.createDir(path)
    return path
コード例 #2
0
	def file_save_as(self, filepath):
		""" Save the current file to the specified filepath.
			If the destination dir doesn't exist, create it.
			TODO: prompt if save will overwrite existing file
			TODO: add updateRecentFiles flag
		"""
		dirname = os.path.dirname(filepath)
		if not os.path.isdir(dirname):
			os_wrapper.createDir(dirname)
		mc.file(rename=filepath)
		mc.SaveScene()
		recent_files.recents.put(filepath)
		return True
コード例 #3
0
    def createShots(self):
        """ Create the shot(s).

		"""
        success = 0
        existing = 0
        failure = 0
        shots_created = ""
        shots_existing = ""
        shots_failed = ""
        dialog_msg = ""

        for shot in self.shots_to_create:
            shot_datafile = self.getShotDatafile(shot)
            os_wrapper.createDir(os.path.dirname(shot_datafile))

            if self.shot_data.load(shot_datafile):
                existing += 1
                shots_existing += shot + "\n"
            elif self.shot_data.save():
                success += 1
                shots_created += shot + "\n"
            else:
                failure += 1
                shots_failed += shot + "\n"

        if success:
            message = "%d %s created successfully: " % (
                success, verbose.pluralise('shot', success))
            dialog_msg += "%s\n%s\n" % (message, shots_created)
            verbose.message(message + shots_created)

        if existing:
            message = "The following %d shot(s) were not created as they already exist: " % existing
            dialog_msg += "%s\n%s\n" % (message, shots_existing)
            verbose.warning(message + shots_existing)

        if failure:
            message = "The following %d shot(s) could not be created - please check write permissions and try again: " % failure
            dialog_msg += "%s\n%s\n" % (message, shots_failed)
            verbose.error(message + shots_failed)

        # Confirmation dialog
        dialog_title = "Shot Creator Results"
        dialog = prompt.dialog()
        dialog.display(dialog_msg, dialog_title, conf=True)

        self.populateShots()
コード例 #4
0
	def file_snapshot(self, dest_dir=None):
		""" Save a copy (snapshot) of the current scene to the destination
			directory, without changing the current file pointer.
			TODO: implement and test properly
		"""
		current_file = mc.file(query=True, expandName=True)
		# tmp_dir = os.path.join(os.environ['SCNMGR_SAVE_DIR'], '.tmp')
		tmp_dir = dest_dir
		os_wrapper.createDir(tmp_dir)
		scene_name = mc.file(query=True, sceneName=True, shortName=True)
		snapshot_file = os.path.join(tmp_dir, scene_name)

		mc.file(rename=snapshot_file)
		snapshot_scene = mc.file(save=True)
		mc.file(rename=current_file)
		#mc.file(save=True)
		# print("Saved snapshot: %s" % snapshot_scene)
		return snapshot_scene
コード例 #5
0
    def file_save_as(self, filepath):
        """ Save the current file to the specified filepath.
			If the destination dir doesn't exist, create it.
			Nuke automatically prompts if file already exists.
			N.B. try/except to catch RuntimeError when dialog is cancelled.
		"""
        try:
            dirname = os.path.dirname(filepath)
            if not os.path.isdir(dirname):
                os_wrapper.createDir(dirname)
            nuke.scriptSaveAs(filepath)
            recent_files.recents.put(filepath)
            self.update_recents_menu()
            return filepath

        except RuntimeError as e:
            if str(e) != "Cancelled":
                dialog = prompt.dialog()
                dialog.display(str(e), "Error Saving File", conf=True)
            return False
コード例 #6
0
    def set_hip_and_job_vars(self, set_hip_explicit=None):
        """ Set the $HIP and $JOB env vars to the correct location.
			$HIP defaults to user scene dir unless set_hip_explicit is given.
		"""
        if set_hip_explicit is None:
            hip_dir = os_wrapper.absolutePath(
                '$IC_HOUDINI_SCENES_DIR/$IC_USERNAME')
        else:
            hip_dir = os_wrapper.absolutePath(set_hip_explicit)
        job_dir = os_wrapper.absolutePath('$IC_HOUDINI_PROJECT_DIR')

        # Create $HIP dir if it doesn't exist
        if not os.path.isdir(hip_dir):
            os_wrapper.createDir(hip_dir)

        # Set vars
        os.environ['HIP'] = hip_dir
        hou.putenv('HIP', hip_dir)
        os.environ['JOB'] = job_dir
        hou.putenv('JOB', job_dir)
コード例 #7
0
ファイル: database.py プロジェクト: all-in-one-of/icarus
    def newWorker(self, **kwargs):
        """ Create a new worker.
		"""
        workerID = uuid.uuid4().hex  # Generate UUID
        kwargs['id'] = workerID

        # Check name is unique...
        # Look for numeric suffix in brackets, replace with n hashes
        name_ls = []
        for name in self.getWorkerNames():
            suffix_pattern = re.compile(r" \([0-9]*\)$")
            suffix = re.findall(suffix_pattern, name)
            if suffix:
                num_suffix = re.findall(r"\d+", str(suffix))
                num_suffix = int(num_suffix[0])
            else:
                num_suffix = 0

            hashes = "#" * num_suffix
            new_name = re.sub(suffix_pattern, hashes, name)
            name_ls.append(new_name)

        # Keep appending hashes until name is unique
        name = kwargs['name']
        while name in name_ls:
            name += "#"

        # Replace hashes with number
        num_suffix = name.count('#')
        kwargs['name'] = re.sub(r"\#+$", " (%d)" % num_suffix, name)

        # Create worker folder and data file
        workerdir = os.path.join(self.db['workers'], workerID)
        os_wrapper.createDir(workerdir)
        datafile = os.path.join(workerdir, 'workerinfo.json')
        self.write(kwargs, datafile)
        self.queue_logger.info("Created worker %s (%s)" %
                               (kwargs['name'], workerID))
コード例 #8
0
def loadItems(path, _bin, emptyBin=True):
    print "Processing bin: %s" % _bin

    # Empty bin
    if emptyBin:
        bin_contents = _bin.items()
        for item in bin_contents:
            _bin.removeItem(item)
            print "Deleted %s" % item

    # Detect if directories exist. Create if not
    if os.path.isdir(path):
        # Add path contents to bin if directory exists
        itemsLs = os.listdir(path)
        itemsLs = sorted(itemsLs, reverse=True)
        for item in itemsLs:
            itemPath = os.path.join(path, item)
            if os.path.isdir(itemPath):
                _bin.importFolder(itemPath)
                print "Imported %s" % itemPath

    else:
        os_wrapper.createDir(path)
コード例 #9
0
ファイル: realflowOps.py プロジェクト: all-in-one-of/icarus
def preview(scene, EXECUTE_SHELL_COMMAND):
	from . import versionUp
	#getting scene, project and shot settings
	sceneName = scene.getFileName()
	if not sceneName:
		scene.message('Scene must be saved before using preview')
		return
	
	sceneName = sceneName.replace('.flw', '')
	projectDir = scene.getRootPath()
	playblastDir = os.path.join(projectDir, 'preview')
	version = versionUp.vCtrl(playblastDir)
	imgPreviewDir = os.path.join(projectDir, 'preview', version[1], 'images')
	movPreviewDir = os.path.join(projectDir, 'preview', version[1], 'mov')
	width = float(os.environ['IC_RESOLUTION_X'])
	width = int(round(width / 1.5))
	height = float(os.environ['IC_RESOLUTION_Y'])
	height = int(round(height / 1.5))
	startFrame = int(scene.getMinFrame())
	endFrame = int(scene.getLastCachedFrame())
	#creating directories
	os_wrapper.createDir(imgPreviewDir)
	os_wrapper.createDir(movPreviewDir)
	scene.videoPreview(os.path.join(movPreviewDir, sceneName), 
	imgPreviewDir, 
	width, 
	height, 
	True, 
	True, 
	startFrame, 
	endFrame, 
	False, 
	EXECUTE_SHELL_COMMAND)
	#launching viewer
	firstFrame = os.listdir(imgPreviewDir); firstFrame = firstFrame[0] 
	djvOps.viewer(os.path.join(imgPreviewDir, firstFrame))
コード例 #10
0
ファイル: ma_animPbl.py プロジェクト: all-in-one-of/icarus
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)
コード例 #11
0
ファイル: ma_mdlPbl.py プロジェクト: all-in-one-of/icarus
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)
コード例 #12
0
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)
コード例 #13
0
def publish(renderDic, pblTo, mainLayer, streamPbl, pblNotes):

    job = os.environ['IC_JOB']
    assetType = 'render'
    prefix = ''
    convention = ''
    suffix = ''
    subsetName = os.environ['IC_SHOT']
    assetExt = ''
    assetPblName = '%s%s%s' % (prefix, convention, suffix)
    assetName = assetPblName

    # Process asset publish options
    assetPblName, assetDir, pblDir = pblOptsPrc.prc(pblTo, subsetName,
                                                    assetType, prefix,
                                                    convention, suffix)
    renderRootPblDir = pblDir

    # Version control
    currentVersion = vCtrl.version(pblDir, current=True)
    version = vCtrl.version(pblDir)

    # Checks if no main layer was set and cancels publish if publishing first version
    if version == 'v001':
        if not mainLayer:
            verbose.noMainLayer()
            return

    # Confirmation dialog
    dialogMsg = ''
    dialogTitle = 'Publishing Render'
    if not streamPbl:
        dialogMsg += "Warning:\n\nPublish won't be streamed.\nLayers from previous renders will not be ported.\n\n\n"
    if not mainLayer:
        dialogMsg += 'Warning:\n\nNo main layer was set.\nThe main render layer will be ported from the previous publish.\n\nContinue?\n\n\n'
    dialogMsg += 'Render:\t%s\n\nVersion:\t%s\n\nNotes:\t%s' % (
        assetPblName, version, pblNotes)
    dialog = prompt.dialog()
    if not dialog.display(dialogMsg, dialogTitle):
        return

    try:
        verbose.pblFeed(begin=True)
        pblResult = 'SUCCESS'

        # Create publish directories
        pblDir = os_wrapper.createDir(os.path.join(pblDir, version))

        # Create in-progress tmp file
        inProgress.start(pblDir)

        # File operations
        if not mainLayer:
            streamPbl = True
        elif version == 'v001':
            streamPbl = True
        # Streaming publish. Hard linking previous version and removing previous icarus data files
        if streamPbl:
            if version != 'v001':
                # Get all layers in current publish
                currentPblLayerLs = os.listdir(
                    os.path.join(renderRootPblDir, currentVersion))
                for currentPblLayer in currentPblLayerLs:
                    # Create respective layer folder in new version
                    if os.path.isdir(
                            os.path.join(renderRootPblDir, currentVersion,
                                         currentPblLayer)):
                        os_wrapper.createDir(
                            os.path.join(pblDir, currentPblLayer))
                        # Get all files in current layer
                        currentLayerFileLs = sorted(
                            os.listdir(
                                os.path.join(renderRootPblDir, currentVersion,
                                             currentPblLayer)))
                        # Hard linking files to new version
                        for currentLayerFile in currentLayerFileLs:
                            verbose.pblFeed(msg='Processing %s' %
                                            currentLayerFile)
                            os_wrapper.hardLink(
                                os.path.join(renderRootPblDir, currentVersion,
                                             currentPblLayer,
                                             currentLayerFile),
                                os.path.join(pblDir, currentPblLayer))

        # Process all new layers and passes
        for key in renderDic.keys():
            srcLayerDir = os.path.expandvars(
                renderDic[key])  # expand environment variables in render path
            dirContents = sorted(os.listdir(srcLayerDir))
            for file_ in dirContents:
                verbose.pblFeed(msg='Processing %s' % file_)
                if key == mainLayer:
                    os_wrapper.createDir(os.path.join(pblDir, 'main'))
                    #if os.path.isfile(os.path.join(srcLayerDir, file_)):
                    #	prcFile = pblOptsPrc.renderName_prc(key, 'main', file_)
                    #	if prcFile:
                    #		os_wrapper.hardLink(os.path.join(srcLayerDir, file_), os.path.join(pblDir, 'main', prcFile))
                    os_wrapper.hardLink(os.path.join(srcLayerDir, file_),
                                        os.path.join(pblDir, key))
                else:
                    destLayerDir = os.path.join(pblDir, key)
                    if not os.path.isdir(destLayerDir):
                        os_wrapper.createDir(destLayerDir)
                    os_wrapper.hardLink(os.path.join(srcLayerDir, file_),
                                        destLayerDir)

        # Create publish snapshot from main layer new version
        mainLayerDir = os.path.join(pblDir, 'main')
        mainLayerFileLs = sorted(os.listdir(mainLayerDir))
        mainLayerPaddingLs = []
        snapShot = False
        #print(mainLayerFileLs)
        for mainLayerFile in mainLayerFileLs:
            #if '_main.' in mainLayerFile:
            if '_main' in mainLayerFile:  # use regex for better matching
                snapShot = True
                mainLayerBody, mainLayerPadding, mainLayerExtension = pblOptsPrc.render_split(
                    mainLayerFile)
                mainLayerPaddingLs.append(mainLayerPadding)

        if snapShot:
            verbose.pblSaveSnapshot()
            startFrame = int(min(mainLayerPaddingLs))
            endFrame = int(max(mainLayerPaddingLs))
            # midFrame = int((int(startFrame) + int(endFrame))/2)

            try:
                posterFrame = int(os.environ['IC_POSTER_FRAME'])
            except ValueError:
                posterFrame = -1
            if not (
                    startFrame <= posterFrame <= endFrame
            ):  # if poster frame is not within frame range, use mid frame
                posterFrame = int((startFrame + endFrame) / 2)

            inFile = os.path.join(mainLayerDir, mainLayerBody)
            outFile = os.path.join(pblDir, 'preview')
            djvOps.prcImg(inFile,
                          outFile,
                          posterFrame,
                          posterFrame,
                          mainLayerExtension[1:],
                          resize=(512, 288),
                          outExt='jpg')
            #djvOps.prcQt(inFile, pblDir, startFrame, endFrame, mainLayerExtension, resize=(256,144))

        # Store asset metadata in file
        assetPblName += '_%s' % version
        # src = renderDic['main']
        src = None
        icPblData.writeData(pblDir, assetPblName, assetName, assetType,
                            assetExt, version, pblNotes, src)

        # Delete in-progress tmp file
        inProgress.end(pblDir)

        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 = "Render:\t%s\n\nVersion:\t%s\n\n\n%s" % (assetPblName, version,
                                                         pblResult)
    dialog = prompt.dialog()
    dialog.display(dialogMsg, dialogTitle, conf=True)
コード例 #14
0
ファイル: ma_scnPbl.py プロジェクト: all-in-one-of/icarus
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)
コード例 #15
0
def publish(dailyPblOpts, pblTo, pblNotes):

	dailySeq, dailyRange, dailyType, dailyPath = dailyPblOpts
	#nameBody, extension = os.path.splitext(dailySeq)
	#extension = extension[1:] # remove leading dot from file extension
	nameBody, padding_, extension = dailySeq.rsplit('.', 2)
	padding = len(padding_)

	job = os.environ['IC_JOB']
	assetType = 'dailies'
	prefix = ''
	convention = ''
	suffix = ''
	subsetName = dailyType
	assetExt = ''
	assetPblName = '%s%s%s' % (prefix, convention, suffix)
	assetName = assetPblName
	shotSaneName = os.environ['IC_SHOT'].replace('/', '_')

	# Process asset publish options
	assetPblName, assetDir, pblDir = pblOptsPrc.prc(pblTo, subsetName, assetType, prefix, convention, suffix)
	renderRootPblDir = pblDir

	# Version control
	currentVersion = vCtrl.version(pblDir, current=True)
	version = vCtrl.version(pblDir)

	# Confirmation dialog
	dialogMsg = ''
	dialogTitle = 'Publishing'
	dialogMsg += 'Name:\t%s_%s\n\nVersion:\t%s\n\nNotes:\t%s' % (shotSaneName, subsetName, version, pblNotes)
	dialog = prompt.dialog()
	if not dialog.display(dialogMsg, dialogTitle):
		return

	try:	
		verbose.pblFeed(begin=True)
		pblResult = 'SUCCESS'

		# Create publish directories
		pblDir = os_wrapper.createDir(os.path.join(pblDir, version))

		# Create in-progress tmp file
		inProgress.start(pblDir)

		# File operations
		dailyPath = os.path.expandvars(dailyPath)

		try:
			startFrame, endFrame = dailyRange.split('-')
		except ValueError:
			startFrame = endFrame = dailyRange # if frame range is a single frame

		try:
			posterFrame_ = int(os.environ['IC_POSTER_FRAME'])
		except ValueError:
			posterFrame_ = -1
		if not (int(startFrame) <= posterFrame_ <= int(endFrame)): # if poster frame is not within frame range, use mid frame
			posterFrame_ = (int(startFrame)+int(endFrame)) / 2
		posterFrame = str(posterFrame_).zfill(padding)

		# Pass arguments to djv to process the files in djvOps
		dailyFileBody = '%s_dailies_%s' % (shotSaneName, subsetName)
		dailyFile = '%s.%s.jpg' % (dailyFileBody, startFrame)
		inFile = os.path.join(dailyPath, nameBody)
		#print(inFile)
		outFile = os.path.join(pblDir, dailyFileBody)
		#djvOps.prcImg(inFile, outFile, startFrame, endFrame, extension, outExt='jpg', fps=os.environ['IC_FPS'])
		djvOps.prcQt(inFile, pblDir, startFrame, endFrame, extension, name='%s_%s' % (dailyFileBody, version))

		# Hard linking daily to dated folder in wips dir
		dailyFileLs = os.listdir(pblDir)
		dailyDateDir = time.strftime('%Y_%m_%d')
		dailyDatePath = os.path.join(os.environ['IC_WIPS_DIR'], 'CGI', dailyDateDir, '%s_%s_%s' % (shotSaneName, subsetName, version))
		os_wrapper.createDir(dailyDatePath)
		excludeLs = ['in_progress.tmp']
		for file_ in dailyFileLs:
			if file_ not in excludeLs:
				os_wrapper.hardLink(os.path.join(pblDir, file_), os.path.join(dailyDatePath, file_))
				dailyFile = file_

		# Create daily snapshot
		previewoutFile = os.path.join(pblDir, 'preview')

		djvOps.prcImg(inFile, previewoutFile, posterFrame, posterFrame, extension, resize=(512,288), outExt='jpg')
		#djvOps.prcQt(inFile, pblDir, startFrame, endFrame, extension, resize=(512,288))

		# Store asset metadata in file
		assetPblName += '_%s' % version
		#src = renderDic['main']
		src = dailySeq
		icPblData.writeData(pblDir, assetPblName, assetName, assetType, assetExt, version, pblNotes, src)

		# Delete in-progress tmp file
		inProgress.end(pblDir)
		inProgress.end(dailyDatePath)

		# Published asset check
		pblDirResult = pblChk.success(os.path.join(pblDir, dailyFile))
		dailyDirResult = pblChk.success(os.path.join(dailyDatePath, dailyFile))
		print(os.path.join(pblDir, dailyFile))
		print(os.path.join(dailyDatePath, dailyFile))
		pblResult = 'SUCCESS'
		if pblDirResult != pblResult or dailyDirResult != pblResult:
			pblResult = 'FAILED'
			raise Exception(verbose.dailyFail())

		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)
		os_wrapper.remove(dailyDatePath)
		pblResult = pblChk.success(pathToPblAsset)
		pblResult += " - " + verbose.pblRollback()

	# Show publish result dialog
	dialogTitle = "Publish Report"
	dialogMsg = "Render:\t%s\n\nVersion:\t%s\n\n%s" % (assetPblName, version, pblResult)
	dialog = prompt.dialog()
	dialog.display(dialogMsg, dialogTitle, conf=True)
コード例 #16
0
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
    shot_ = os.environ['IC_SHOT']
    assetType = 'ic_camera'
    subsetName = ''
    prefix = ''
    convention = subtype
    suffix = '_camera'
    fileType = 'mayaAscii'
    extension = 'ma'

    # Get all dependents
    allObjLs = mc.listRelatives(objLs[0], ad=True, f=True, typ='transform')
    if allObjLs:
        allObjLs.append(objLs[0])
    else:
        allObjLs = [objLs[0]]

    # Check if selection is a camera
    if not mayaOps.cameraNodeCheck(objLs[0]):
        verbose.notCamera()
        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)
    assetPblName += '_%s' % slShot

    # Version control
    version = '%s' % vCtrl.version(pblDir)
    #	if approved:
    #		version += '_apv'

    # Confirmation dialog
    dialogTitle = 'Publishing %s' % assetPblName  # 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)
        icPblData.writeData(pblDir, assetPblName, assetPblName, assetType,
                            extension, version, pblNotes, src)

        # Maya operations
        mayaOps.deleteICDataSet(allObjLs)
        newcamLs = mayaOps.cameraBake(objLs, assetPblName)
        objLs = [newcamLs[0]]
        attrLs = [
            '.tx', '.ty', '.tz', '.rx', '.ry', '.rz', '.sx', '.sy', '.sz'
        ]
        mayaOps.lockAttr(objLs, attrLs)

        # File operations
        pathToPblAsset = os.path.join(pblDir,
                                      '%s.%s' % (assetPblName, extension))
        verbose.pblFeed(msg=assetPblName)
        mayaOps.exportSelection(pathToPblAsset, fileType)
        mayaOps.nkCameraExport(objLs, pblDir, assetPblName, version)
        mayaOps.exportGeo(objLs, 'fbx', pathToPblAsset)
        #	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)
コード例 #17
0
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)
コード例 #18
0
ファイル: database.py プロジェクト: all-in-one-of/icarus
    def create(self):
        """ Create the database directory structure.
		"""
        for directory in self.db.values():
            os_wrapper.createDir(directory)
コード例 #19
0
ファイル: nk_compPbl.py プロジェクト: all-in-one-of/icarus
def publish(pblTo, slShot, subtype, pblNotes):

	# Get selection
	nodeLs = nuke.root().nodes()

	# Define main variables
	shot_ = ''
	assetType = 'nk_%s' % subtype
	subsetName = ''
	prefix = ''
	convention = subtype
	suffix = ''
	fileType='nk'
	extension = 'nk'

	# 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)

		# File operations
		pathToPblAsset = os.path.join(pblDir, '%s.%s' % (assetPblName, extension))
		verbose.pblFeed(msg=assetPblName)
		# nukeOps.saveAs(pathToPblAsset)
		nuke.scriptSaveAs(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)
コード例 #20
0
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)
コード例 #21
0
def publish(pblTo, pblNotes):

	# Define main variables
	assetType = 'ma_shot'
	subsetName = ''
	prefix = ''
	convention = os.environ['IC_SHOT']
	suffix = '_shot'
	fileType = 'mayaAscii'
	extension = 'ma'

	# Process asset publish options
	assetPblName, assetDir, pblDir = pblOptsPrc.prc(pblTo, subsetName, assetType, prefix, convention, suffix)

	# 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))
		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, assetPblName, assetType, extension, version, pblNotes, src)

		# Publish operations
		# 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 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)