def publishFile(self, *args): # get database info on item item = Item(task=self.task, code=self.code, itemType=self.type) item.proxyMode = self.proxyMode item.publishAs() version.takeSnapShot(item.getDataDict()) self.closeWin() logger.debug('publish ver %s, at %s' % (item.publishVer, item.getPublishPath())) resp = pm.confirmDialog( title='Warning', ma='center', message='PUBLISH: %s %s \n Reopen working task?' % (item.name, item.task), button=['Ok', 'No'], defaultButton='Ok', dismissString='No') if resp == 'Ok': version.open(type=item.type, task=item.task, code=item.code, force=True) else: pm.newFile(f=True, new=True)
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()