Exemplo n.º 1
0
def run(SCENEPATH):
    # print MAYA_PYTHON, MAYACMD, ARPATH, ADPATH, ADNAME, ASSETNAME
    logger.info('Start exporting asmAssetLocator ...')
    asset = entityInfo.info(SCENEPATH)
    locPath = '%s/%s' % (asset.getPath('ref'), asset.getRefNaming('loc'))

    mtime = None

    if os.path.exists(locPath):
        logger.debug('File exists. Backing up ...')
        backupResult = pipelineTools.backupRef(locPath)
        logger.debug('Backup complete %s' % locPath)

        mtime = os.path.getmtime(locPath)
        logger.debug('mtime %s' % mtime)

    logFile = 'asmExportLoc_%s.log' % str(datetime.now()).replace(
        ' ', '_').replace(':', '-').split('.')[0]
    logPath = '%s/%s/%s' % (asset.getPath('log'), 'asmLocator', logFile)
    # logPath = LOG

    logger.info('running batch ...')
    chk = subprocess.call([MAYA_PYTHON, MAYACMD, SCENEPATH])
    logger.debug('batch complete')
    chk = ''
Exemplo n.º 2
0
def publishAD(arFile='') : 
    """ publish ad file from dress work """
    logger.info('Publishing AD file ...')
    asset = entityInfo.info()
    if not arFile: 
        arFile = '%s/%s' % (asset.getPath('ref'), asset.getRefNaming('ar'))
    adFile = '%s/%s' % (asset.getPath('ref'), asset.getRefNaming('ad'))
    adName = '%s_ad' % (asset.name())

    createAD.SCENEPATH = asset.thisScene()
    createAD.ARPATH = arFile
    createAD.ADPATH = adFile
    createAD.ADNAME = adName
    createAD.ASSETNAME = asset.name()

    logger.debug('setting param ... ')
    logger.debug('param createAD.SCENEPATH : %s' % createAD.SCENEPATH)
    logger.debug('param createAD.ARPATH : %s' % createAD.ARPATH)
    logger.debug('param createAD.ADPATH : %s' % createAD.ADPATH)
    logger.debug('param createAD.ADNAME : %s' % createAD.ADNAME)
    logger.debug('param createAD.ASSETNAME : %s' % createAD.ASSETNAME)
    mtime = None
    
    if os.path.exists(adFile):
        mtime = os.path.getmtime(adFile)
        logger.debug('File exists. Backing up %s' % arFile)
        backupResult = pipelineTools.backupRef(adFile) 
        logger.debug('Backup complete %s' % backupResult)

    try:
        # pipelineTools.backupRef(self.adPath)
        logger.debug('Running batch create AD ...')
        logPath = createAD.run()
        logger.debug('Batch complete %s' % logPath)

    except Exception as e : 
        logger.error('Error %s' % e)

    if os.path.exists(adFile) : 
        if mtime : 
            newMtime = os.path.getmtime(adFile)
            logger.debug('mtime %s, newMTime %s' % (mtime, newMtime))

            if not newMtime == mtime : 
                logger.info('Publish AD complete %s' % adFile)
                return adFile

            else : 
                logger.error('Batch publish AD failed. File maybe locked. %s' % adFile)

        else : 
            logger.info('Publish AD complete %s' % adFile)
            return adFile
Exemplo n.º 3
0
def exportGeo(asset, batch = True) : 
	refPath = asset.getPath('ref')
	refFile = asset.getRefNaming('geo')
	src = asset.thisScene()
	dst = '%s/%s' % (refPath, refFile)
	status = False
	message = str()
	returnResult = dict()

	if batch : 
		# back up
		backupResult = pt.backupRef(dst)

		# publish
		cmds = "['clean']"
		rigPublish.run(src, dst, cmds, setting.exportGrp, 'export')

		if backupResult : 
			backupMTime = backupResult[1]
			currentMTime = os.path.getmtime(dst)
			returnResult.update({'Backup Ref file': {'status': True, 'message': ''}})


			if backupMTime == currentMTime : 
				status = False 
				message = 'File export failed'
				# print 'File export failed'

			else : 
				status = True 
				message = 'Export overwriten success %s' % dst
				# print 'Export overwriten success %s' % dst

		else : 
			if os.path.exists(dst) : 
				status = True
				message = 'Export success %s' % dst
				# print 'Export success %s' % dst



	else : 
	    pt.importRef() 
	    pt.clean()
	    mc.file(rename = dst)
	    result = mc.file(save = True, type = 'mayaAscii', f = True)

	    if result : 
	    	status = True

	returnResult.update({'Export %s' % refFile: {'status': status, 'message': message, 'hero': dst}})

	return returnResult
Exemplo n.º 4
0
def exportRig(asset, batch):
    refPath = asset.getPath("ref")
    refFile = asset.getRefNaming("anim")
    src = asset.thisScene()
    dst = "%s/%s" % (refPath, refFile)
    status = False
    message = str()
    returnResult = dict()

    if batch:
        # back up
        backupResult = pt.backupRef(dst)

        # publish
        cmds = "['importRef', 'clean', 'removeSet', 'removeFixSet']"
        rigPublish.run(src, dst, cmds)

        if backupResult:
            backupMTime = backupResult[1]
            currentMTime = os.path.getmtime(dst)
            returnResult.update({"Backup Ref file": {"status": True, "message": ""}})

            if backupMTime == currentMTime:
                status = False
                message = "File export failed"
                # print 'File export failed'

            else:
                status = True
                message = "Export overwriten success %s" % dst
                # print 'Export overwriten success %s' % dst

        else:
            if os.path.exists(dst):
                status = True
                message = "Export success %s" % dst
                # print 'Export success %s' % dst

    else:
        pt.importRef()
        pt.clean()
        mc.file(rename=dst)
        result = mc.file(save=True, type="mayaAscii", f=True)

        if result:
            status = True

    returnResult.update({"Export %s" % refFile: {"status": status, "message": message, "hero": dst}})

    return returnResult
Exemplo n.º 5
0
def run(SCENEPATH):
    # print MAYA_PYTHON, MAYACMD, ARPATH, ADPATH, ADNAME, ASSETNAME
    logger.info('Start exporting asmAssetLocator ...')
    asset = entityInfo.info(SCENEPATH)
    locPath = '%s/%s' % (asset.getPath('ref'), asset.getRefNaming('loc'))

    mtime = None

    if os.path.exists(locPath):
        logger.debug('File exists. Backing up ...')
        backupResult = pipelineTools.backupRef(locPath)
        logger.debug('Backup complete %s' % locPath)

        mtime = os.path.getmtime(locPath)
        logger.debug('mtime %s' % mtime)

    logFile = 'asmExportLoc_%s.log' % str(datetime.now()).replace(
        ' ', '_').replace(':', '-').split('.')[0]
    logPath = '%s/%s/%s' % (asset.getPath('log'), 'asmLocator', logFile)
    # logPath = LOG

    logger.info('running batch ...')
    chk = subprocess.call([MAYA_PYTHON, MAYACMD, SCENEPATH])
    logger.debug('batch complete')
    chk = ''

    if not os.path.exists(os.path.dirname(logPath)):
        os.makedirs(os.path.dirname(logPath))

    logger.debug('writing log ...')
    f = open(logPath, 'w')
    f.write(chk)
    f.close()
    logger.debug('Complete. %s' % logPath)

    if os.path.exists(locPath):
        if mtime:
            newMTime = os.path.getmtime(locPath)

            if not newMTime == mtime:
                logger.info('Export complete : %s' % locPath)
                return locPath

            else:
                logger.error('Export failed. File maybe locked %s' % locPath)

        else:
            logger.info('Export complete : %s' % locPath)
            return locPath
Exemplo n.º 6
0
def publishAR(source) : 
    """ publish AR from dress work """
    logger.info('Publishing AR file ...')

    if os.path.exists(source) : 
        asset = entityInfo.info()
        arFile = '%s/%s' % (asset.getPath('ref'), asset.getRefNaming('ar'))


        if os.path.exists(arFile) : 
            logger.debug('File exists. Backing up %s' % arFile)
            backupResult = pipelineTools.backupRef(arFile)
            logger.debug('Backup complete %s' % backupResult)

        logger.debug('Copying %s to %s' % (source, arFile))
        result = fileUtils.copy(source, arFile)
        logger.info('Publish complete')

        return result

    else : 
        logger.warning('%s not exists. Publihsing stop.' % source)
Exemplo n.º 7
0
def exportCmd(asset, title, src, dst, cmds, content = '', output = 'save') : 
	returnResult = dict()
	message = str()
	status = False

	# back up
	backupResult = pt.backupRef(dst)

	# publish
	# cmds = "['importRef', 'clean', 'removeSet']"
	rigPublish.run(src, dst, cmds, content, output)

	if backupResult : 
		backupMTime = backupResult[1]
		currentMTime = os.path.getmtime(dst)
		returnResult.update({'Backup Ref file': {'status': True, 'message': ''}})


		if backupMTime == currentMTime : 
			status = False 
			message = 'File export failed'
			# print 'File export failed'

		else : 
			status = True 
			message = 'Export overwriten success %s' % dst
			# print 'Export overwriten success %s' % dst

	else : 
		if os.path.exists(dst) : 
			status = True
			message = 'Export success %s' % dst
			# print 'Export success %s' % dst


	returnResult.update({title: {'status': status, 'message': message, 'hero': dst}})

	return returnResult
Exemplo n.º 8
0
def exportShade(asset, title) : 
	from tool.ptAlembic import exportShade as es
	reload(es)

	name = '%s_Shade' % asset.name()
	exportPath = asset.getPath('ref')
	exportName = '%s/%s' % (exportPath, name)

	# lock vray mtrl
	# mtrs = mc.ls(type = 'VRayMtl') + mc.ls(type = 'VRayBlendMtl')

	# for each in mtrs : 
	#     mc.setAttr('%s.vrayMaterialId' % each, l = True)

	# backup
	backupShadeFile = None 
	backupDataFile = None 
	
	if os.path.exists('%s.ma' % exportName) : 
		backupShadeFile = pt.backupRef('%s.ma' % exportName)

	if os.path.exists('%s.yml' % exportName) : 
		backupDataFile = pt.backupRef('%s.yml' % exportName)

	# run command export shade
	result = es.doShadeExport()
	returnResult = dict()

	status = False 
	message = 'Failed to export'
	dst = ''

	if result : 
		shadeFile = result[0]
		dataFile = result[1]

		status = True 
		message = 'Shade / Data export complete'


		if backupShadeFile and backupDataFile : 
			backupSMTime = backupShadeFile[1]
			backupDMTime = backupDataFile[1]
			currentSMTime = os.path.getmtime(shadeFile)
			currentDMTime = os.path.getmtime(dataFile)

			if backupSMTime == currentSMTime : 
				status = False 
				message = 'ShadeFile export failed'

			else : 
				status = True 
				message = 'ShadeFile export complete'

			if backupDMTime == currentDMTime : 
				status = False 
				message = 'DataFile export failed'

			else : 
				status = True 
				message = 'DataFile export complete'

		hero = '%s/%s' % (shadeFile, dataFile)


	returnResult.update({title: {'status': status, 'message': message, 'hero': hero}})
	return returnResult