def createAssetCallBack(self, *args): name = pm.textFieldGrp('CrAsset_nameField', q=True, tx=True) if not name: return pm.confirmDialog( title='error', ma='center', message='please choose a name for the asset', button=['OK'], defaultButton='OK', dismissString='OK') workflow = pm.optionMenuGrp('CrAsset_workflowOpt', q=True, v=True) code = pm.textFieldGrp('CrAsset_codeField', q=True, tx=True) itemDict = database.createItem(self.type, name, self.path, workflow, code) print itemDict if itemDict == 'codeExists': return pm.confirmDialog(title='error', ma='center', message='this code already exists', button=['OK'], defaultButton='OK', dismissString='OK') pm.layoutDialog(dismiss='ok')
def ingestSet(descFileName, pathSrc, pathTgt): descDict = readDescription(descFileName, pathSrc, level=1, maxDepth=0, searchInGroupAsset=True) descName, file_extension = os.path.splitext(descFileName) fileName = descName.split('_')[0] ver = descName.split('.')[-1] ingestionDict = { 'name': fileName, 'version': ver, 'sourcePath': pathSrc, 'assetType': 'group', 'task': 'proxy', 'setAssemble': '' } database.incrementNextCode('asset', fromBegining=True) itemMData = database.createItem(itemType='asset', name=fileName, path=pathTgt, workflow='group', customData={'ingestData': ingestionDict}) progressWin = ProgressWindowWidget(title='Set', maxValue=2) addComponentsToSet(item=itemMData['proxy'], onSceneParent='', components=descDict, proxyMode='proxy') progressWin.progressUpdate(1) addComponentsToSet(item=itemMData['model'], onSceneParent='', components=descDict, proxyMode='model') progressWin.progressUpdate(1) progressWin.closeWindow()
def ingestGroups(pathSrc, pathTgt): groupPath = r'wolftv\asset\group' proxyModelPath = r'modeling\proxy_model\desc' groupsFullPath = os.path.join(pathSrc, groupPath) logger.debug('groupFullPath: %s' % groupsFullPath) fileList = pm.getFileList(folder=groupsFullPath) progressWin = ProgressWindowWidget(title='groups', maxValue=len(fileList)) for group in fileList: logger.info('importing %s to pipeLine' % group) progressWin.progressUpdate(1) fileName = group versionPath = os.path.join(groupsFullPath, fileName, proxyModelPath) versionsAvailable = pm.getFileList(folder=versionPath) maxVer = 0 for ver in versionsAvailable: verNum = int(ver[1:]) maxVer = max(maxVer, verNum) version = 'v%03d' % maxVer groupFullPath = os.path.join(versionPath, version) groupFile = pm.getFileList(folder=groupFullPath)[0] groupFullPath = os.path.join(groupFullPath, groupFile) ingestionDict = { 'name': fileName, 'version': maxVer, 'sourcePath': groupFullPath, 'assetType': 'group', 'task': 'proxy', 'setAssemble': os.path.split(pathSrc)[-1] } database.incrementNextCode('asset', fromBegining=True) itemMData = database.createItem( itemType='asset', name=fileName, path=pathTgt, workflow='group', customData={'ingestData': ingestionDict}) itemProxy = Item(task='proxy', code=itemMData['proxy']['code']) itemModel = Item(task='model', code=itemMData['model']['code']) descDict = readDescription(groupFullPath, 1, maxDepth=0, searchInGroupAsset=True) for component in descDict: logger.debug('add %s to %s' % (component['name'], fileName)) itemList = database.searchName(component['name']) if 0 < len(itemList) > 1: proxyComponentMData = database.addSource( item=itemProxy.getDataDict(), ns='ref', componentCode=itemList[0]['code'], componentTask='proxy', assembleMode='reference', update=True, proxyMode='proxy', xform=component['xform'], onSceneParent='') modelComponentMData = database.addSource( item=itemModel.getDataDict(), ns='ref', componentCode=itemList[0]['code'], componentTask='proxy', assembleMode='reference', update=True, proxyMode='model', xform=component['xform'], onSceneParent='') progressWin.closeWindow()
def ingestPieces(pathSrc, pathTgt): setPiecesPath = r'wolftv\asset\set_piece' proxyModelPath = r'modeling\proxy_model\source' setPiecesFullPath = os.path.join(pathSrc, setPiecesPath) fileList = pm.getFileList(folder=setPiecesFullPath) progressWin = ProgressWindowWidget(title='set pieces', maxValue=len(fileList)) for piece in fileList: logger.info('importing %s to pipeLine' % piece) progressWin.progressUpdate(1) fileName = piece versionPath = os.path.join(setPiecesFullPath, fileName, proxyModelPath) versionsAvailable = pm.getFileList(folder=versionPath) maxVer = 0 for ver in versionsAvailable: verNum = int(ver[1:]) maxVer = max(maxVer, verNum) version = 'v%03d' % maxVer pieceFullPath = os.path.join(versionPath, version) pieceFile = pm.getFileList(folder=pieceFullPath)[0] pieceFullPath = os.path.join(pieceFullPath, pieceFile) ingestionDict = { 'name': fileName, 'version': maxVer, 'sourcePath': pieceFullPath, 'assetType': 'set_piece', 'task': 'proxy', 'setAssemble': os.path.split(pathSrc)[-1] } database.incrementNextCode('asset', fromBegining=True) itemMData = database.createItem( itemType='asset', name=fileName, path=pathTgt, workflow='static', customData={'ingestData': ingestionDict}) item = Item(task='proxy', code=itemMData['proxy']['code']) item.status = 'created' item.putDataToDB() workPath = item.getWorkPath(make=True) shutil.copyfile(pieceFullPath, workPath) prj = database.getCurrentProject() insertFileInfo(workPath, projectName=prj, task=item.task, code=item.code, type=item.type) # done copy to publish folder item.publishVer += 1 publishPath = item.getPublishPath(make=True) shutil.copyfile(workPath, publishPath) item.putDataToDB() logger.info('%s imported as %s and published' % (piece, item.task + item.code + item.name)) progressWin.closeWindow()
for piece in fileList: fileName = piece versionPath = os.path.join(setPiecesFullPath, fileName, proxyModelPath) versionsAvailable = pm.getFileList(folder=versionPath) maxVer = 0 for ver in versionsAvailable: verNum = int(ver[1:]) maxVer = max(maxVer, verNum) version = 'v%03d' % maxVer pieceFullPath = os.path.join(versionPath, version) pieceFile = pm.getFileList(folder=pieceFullPath)[0] pieceFullPath = os.path.join(pieceFullPath, pieceFile) print pieceFullPath ingestionDict = { 'name': fileName, 'version': maxVer, 'sourcePath': pieceFullPath, 'assetType': 'set_piece', 'task': 'proxy', 'setAssemble': os.path.split(pathSrc)[-1] } print ingestionDict print database.createItem(itemType='asset', name=fileName, path=pathTgt, workflow='static')