Esempio n. 1
0
def copy_media_version(prod_dir='',publ_dir='',versionName=''):

    for media in file_utils.listFile(prod_dir):
        if versionName in media:
            prod_path = prod_dir + '/' + media
            publ_path = publ_dir + '/' + media
            print file_utils.copy(prod_path,publ_path)
Esempio n. 2
0
def export_abc(entity=None):
    """ export alembic geo """
    status = False
    exportGrp = config.geoGrp
    res = entity.task_res()
    libPath = entity.libPath()
    publishResult = False

    if res:
        abcModel = entity.libName(entity.step, res, ext='abc')
        exportPath = '{0}/{1}'.format(libPath, abcModel)
        exportExt = os.path.splitext(exportPath)[-1]

        # check file
        start = pub_utils.file_time(exportPath)

        # export command
        abc_utils.exportABC(exportGrp, exportPath)

        # check file export success
        end = pub_utils.file_time(exportPath)
        exportResult = pub_utils.is_file_new(start, end)

        # write info
        if ui:
            publishFile = str(ui.publishVersionLabel.text())
            pubEntity = path_info.PathInfo(publishFile)

            # publish
            publishPath = pubEntity.publishPath(publish='output')
            publishName = pubEntity.basename(ext=False)
            publishFileName = '%s/%s%s' % (publishPath, publishName, exportExt)
            file_utils.copy(exportPath, publishFileName)

            if os.path.exists(publishFileName):
                publishResult = True

            # write info
            info = publish_info.TaskInfo(pubEntity)
            info.set('secondaryOutput', 'abc', publishFileName)
            info.set('secondaryOutput', 'abcHero', exportPath)
            # successPublishFile = info.get('primaryOutput', 'publishFile')

        if exportResult:
            if publishResult:
                return True, 'Success %s\n%s' % (exportPath, publishFileName)

            else:
                return False, 'Failed to publish %s' % publishFileName

        else:
            return False, 'Failed to export Alembic %s' % exportPath

    else:
        return False, 'No res found'
Esempio n. 3
0
def check_ad(entity=None):
    if ui:
        publishFile = str(ui.publishVersionLabel.text())
        pubEntity = path_info.PathInfo(publishFile)
        libPath = pubEntity.libPath()
        adFile = pubEntity.libName('ad', '')

        steps = template.workSceneSteps
        templatePath = '%s/RFPROJECT' % template.templatePath

        src = '%s/%s/%s' % (templatePath, 'lib', 'asset_ad.ma')
        dst = '%s/%s' % (libPath, adFile)

        if not os.path.exists(dst):
            start = pub_utils.file_time(dst)

            result = file_utils.copy(src, dst)
            repathResult = pipeline_utils.repath_ad(pubEntity)

            # check file export success
            end = pub_utils.file_time(dst)
            exportResult = pub_utils.is_file_new(start, end)

            if exportResult:
                return True, 'Success \n%s' % dst

            else:
                return False, 'Failed repath ad %s' % exportResult

        else:
            return True, '%s exists' % adFile

    else:
        return False, 'no ui information'
Esempio n. 4
0
def publish_geo(entity=None):
    """ copy publised model to lib """
    if ui:
        publishFile = str(ui.publishVersionLabel.text())
        pubEntity = path_info.PathInfo(publishFile)
        info = publish_info.TaskInfo(pubEntity)
        modelPublish = info.get('primaryOutput', 'publishFile')
        libPath = entity.libPath()
        libName = entity.libName(entity.step,
                                 entity.task_res(),
                                 ext=pubEntity.ext)
        dst = '{0}/{1}'.format(libPath, libName)

        # check file
        start = pub_utils.file_time(dst)
        result = file_utils.copy(modelPublish, dst)

        # check file export success
        end = pub_utils.file_time(dst)
        exportResult = pub_utils.is_file_new(start, end)

        if exportResult:
            return True, 'Success \n%s' % dst

        else:
            return False, 'Failed to copy \n%s' % dst

    else:
        return False, 'No ui information.'
Esempio n. 5
0
    def publish(self): 
        data = self.fileData
        dataFilePath = self.entity.dataFile()
        ymlDumper(dataFilePath, data)

        version = self.incrementFile()
        return file_utils.copy(dataFilePath, version)
Esempio n. 6
0
    def move_asset(self): 
        logger.info('move_asset')
        moveRows = self.get_check_items()
        
        for row in moveRows: 

            progressBar = QtWidgets.QProgressBar()
            self.ui.tableWidget.setCellWidget(row, self.columnName.index('Progress'), progressBar)
            progressBar.setMinimum(1)
            progressBar.setMaximum(100)

            assetDict = self.get_asset_info(row)
            asset = assetDict.get('asset')
            source = assetDict.get('source')
            status = assetDict.get('status')
            res = assetDict.get('res')
            libPath = '%s/%s' % (asset.libPath(), asset.libName(asset.step, res, project=False, ext='ma'))
            texturePath = asset.texturePath()

            if os.path.exists(source) and os.path.splitext(source)[-1] in ['.ma', '.mb']: 
                self.set_status(row, 'In progress...')
                # find assets linked 
                self.set_status(row, 'collecting assets ...')
                replaceDict = self.get_replace_info(asset, source, res, progressBar)
                self.set_status(row, 'collect asset complete')

                if replaceDict: 
                    # copy 
                    self.set_status(row, 'copying files ...')
                    self.copy_assets(replaceDict, progressBar)
                # copy scene 
                result = file_utils.copy(source, libPath)
                self.set_status(row, 'copy complete')

                if result: 
                    # repath 
                    self.set_status(row, 'repath ...')
                    
                    if not self.ui.maya_checkBox.isChecked(): 
                        pipeline_utils.search_replace_file(libPath, libPath, replaceDict)

                    else: 
                        self.replace_files(libPath, replaceDict)
                    
                    progressBar.setValue(100)
                    progressBar.hide()
                    logger.info('replace path success\n\n')
                    self.set_status(row, 'Finish')
                    print 'replace path success'
                    self.set_dst_status(row, asset)

            else: 
                self.set_status(row, 'File not valid. Stop.')
Esempio n. 7
0
    def upload_movie(self):
        workspace = mc.workspace(q=True, dir=True)
        fileName = QtGui.QFileDialog.getOpenFileName(
            self, "Open Movie", workspace + '/movies',
            "Movie Files (*.mov *.avi *.mp4)")
        self.movie = self.movie_prod + '.' + fileName[0].split('.')[-1]

        self.show_progressBar()
        i = 0

        while i != 20:
            self.trace('Copying Movie to Server', i)
            i += 1

        file_utils.copy(fileName[0], self.movie)

        while i != 100:
            self.trace('Copying Movie to Server', i)
            i += 1

        self.set_movie()
        self.hide_progressBar()
        self.trace('Ready')
Esempio n. 8
0
def save_file(entity=None):
    """ save increment file to lock wip version """
    errorMessage = []

    if not entity:
        entity = path_info.PathInfo()

    if entity:
        logger.debug('start publishing ...')

        # get publish info
        publishFile, saveWorkFile, incrementSaveWorkFile, libFile = pub_utils.get_publish_info(
            entity)

        logger.debug('save work file %s' % saveWorkFile)
        logger.debug('publish version %s' % publishFile)
        logger.debug('save increment work file %s' % incrementSaveWorkFile)

        # start process files
        saveResult = None
        workResult = None

        # publish info
        pubEntity = path_info.PathInfo(publishFile)
        info = publish_info.TaskInfo(pubEntity)

        # save as
        saveResult = hook.save_file_as(incrementSaveWorkFile)
        info.set('work', 'incrementWorkFile', incrementSaveWorkFile)

        if saveResult:
            # copy to current work version (short cut for overwritten save)
            workResult = file_utils.copy(saveResult, saveWorkFile)
            info.set('work', 'workfile', saveWorkFile)

        if not saveResult:
            logger.error('Save to %s has failed' % incrementSaveWorkFile)
            errorMessage.append('Save to %s has failed' %
                                incrementSaveWorkFile)

        if not workResult:
            logger.error('Overwrite work version %s has failed' % saveWorkFile)
            errorMessage.append('Overwrite work version %s has failed' %
                                saveWorkFile)

    if errorMessage:
        return False, errorMessage

    else:
        return True, 'Success \n%s' % workResult
Esempio n. 9
0
def source_publish(source, dstdir, entity, task):
    """ publish for source file """
    key = 'v'
    padding = 3
    version = 1
    srcBasename = os.path.basename(source)
    ext = os.path.splitext(srcBasename)[-1]
    publishName = '%s_%s_%s%03d%s' % (entity, task, key, version, ext)
    publishFile = '%s/%s' % (dstdir, publishName)
    publishVersion = find_version(publishFile, key='v', padding=padding)

    if publishVersion:
        result = file_utils.copy(source, publishVersion)
        logger.info('Publish source %s to %s successfully' % (source, publishVersion))
        return result
Esempio n. 10
0
def relink_texture():
    fileNodes = mc.ls(type='file')
    asset = path_info.PathInfo()
    texturePath = asset.texturePath()
    res = asset.file_res()
    assetTexturePath = '%s/%s' % (texturePath, res)

    for node in fileNodes:
        path = mc.getAttr('%s.fileTextureName' % node)

        if not assetTexturePath in path:
            # path not valid
            filename = os.path.basename(path)
            newPath = '%s/%s' % (assetTexturePath, filename)

            if not os.path.exists(newPath):
                file_utils.copy(path, newPath)

            # link
            mc.setAttr('%s.fileTextureName' % node, newPath, type='string')
            logger.info('link success %s' % newPath)

        else:
            logger.info('texture already in pipeline %s' % path)
Esempio n. 11
0
    def copy_to_lib(self):
        if os.path.exists(self.pre_gpu):
            file_utils.copy(self.pre_gpu,self.gpu_lib)
            os.remove(self.pre_gpu)

        if os.path.exists(self.pre_abc):
            file_utils.copy(self.pre_abc,self.abc_lib)
            os.remove(self.pre_abc)

        if os.path.exists(self.publ_path):
            file_utils.copy(self.publ_path,self.publ_lib)
Esempio n. 12
0
    def copy_assets(self, replaceDict, progressBar): 
        logger.info('start copying ...')
        processPercent = 50
        num = 0 
        value = progressBar.value()
        increment = processPercent/len(replaceDict.keys())

        for src, dst in replaceDict.iteritems(): 
            result = file_utils.copy(src, dst)
            logger.debug('copied %s' % result)

            if result: 
                num+=1
                progressBar.setValue(num*increment)
                QtWidgets.QApplication.processEvents()

        logger.info('copy %s files success' % num)
Esempio n. 13
0
def create_lib_template(root, project, assetType, assetSubType, assetName):
    scriptServer = os.environ['RFSCRIPT']
    templateLibPath = ''
    templateLibPath = '%s/RFPROJECT/%s' % (template.templatePath, config.ref)

    asset = path_info.PathInfo(project=project,
                               entity=config.asset,
                               entitySub1=assetType,
                               entitySub2=assetSubType,
                               name=assetName)
    assetLibPath = '%s/%s' % (asset.entityPath(root), config.ref)
    libFiles = file_utils.listFile(templateLibPath)

    if not os.path.exists(assetLibPath):
        os.makedirs(assetLibPath)

    for libFile in libFiles:
        src = '%s/%s' % (templateLibPath, libFile)
        dst = '%s/%s' % (assetLibPath, libFile)

        if not os.path.exists(dst):
            result = file_utils.copy(src, dst)
            logger.debug('Copy %s -> %s success' % (src, dst))

            if config.libFileReplaceKw in libFile:
                newName = libFile.replace(config.libFileReplaceKw, asset.name)
                renSrc = dst
                renDst = '%s/%s' % (assetLibPath, newName)

                if not os.path.exists(renDst):
                    os.rename(renSrc, renDst)
                    logger.debug('Rename %s -> %s' % (renSrc, renDst))

                else:
                    os.remove(renSrc)
                    logger.debug('Remove existing template %s' % renSrc)

    create_standin(asset)
    repath_ad(asset)

    return True
Esempio n. 14
0
 def copy_to_src_publ(self):
     mc.file(f=True,s=True)
     print file_utils.copy(self.thisScene,self.src_publ)
Esempio n. 15
0
def publish_image(entity=None):
    """ publish image or movie files """
    mediaExts = ['.mov']
    errorMessage = []
    imgPublishes = []
    if not entity:
        entity = path_info.PathInfo()

    if entity and ui:
        logger.debug('start publishing image ...')

        # get publish info
        publishFile = str(ui.publishVersionLabel.text())
        pubEntity = path_info.PathInfo(publishFile)
        info = publish_info.TaskInfo(pubEntity)
        # successPublishFile = info.get('primaryOutput', 'publishFile')
        successPublishFile = publishFile

        # if publish success
        if successPublishFile:
            publishVer = path_info.find_version(successPublishFile)

            # _media path for hero preview
            mediaPath = entity.mediaPath()
            publishImgPath = entity.publishPath(publish='img')
            publishMovPath = entity.publishPath(publish='mov')

            publishName = entity.publishName()
            publishMediaVersion = entity.publishName(publishVer)

            # get publish items
            paths = ui.snapWidget.get_all_paths()
            heroImgSrc = None
            heroMovSrc = None
            copyDict = dict()

            for i, path in enumerate(paths):
                src = path.replace('\\', '/')
                extension = os.path.splitext(path)[-1]
                basename = '%s_%03d%s' % (publishMediaVersion, i + 1,
                                          extension)

                if extension in mediaExts:
                    dst = '{0}/{1}'.format(publishMovPath, basename)
                    if not heroMovSrc:
                        heroMovSrc = src
                else:
                    dst = '{0}/{1}'.format(publishImgPath, basename)
                    if not heroImgSrc:
                        heroImgSrc = src

                copyDict.update({src: dst})

            # copy to publishes
            for src, dst in copyDict.iteritems():
                try:
                    file_utils.copy(src, dst)
                    logger.debug('Copy to publish %s - %s' % (src, dst))
                    imgPublishes.append(dst)

                except Exception as e:
                    errorMessage.append('Failed to copy %s-%s' % (src, dst))

            info.set('primaryOutput', 'publishImgFiles', imgPublishes)

            # copy to heroImgSrc
            imgExt = os.path.splitext(heroImgSrc)[-1]
            heroImgDst = '%s/%s%s' % (mediaPath, publishName, imgExt)
            heroPreview = '%s/%s%s' % (mediaPath, entity.name, imgExt)

            if heroImgSrc:
                try:
                    file_utils.copy(heroImgSrc, heroImgDst)
                    logger.debug('Copy to hero %s - %s' %
                                 (heroImgSrc, heroImgDst))
                    imgPublishes.append(heroImgDst)
                    info.set('primaryOutput', 'heroImgFile', str(heroImgDst))

                except Exception as e:
                    errorMessage.append('Failed to copy to hero %s-%s' %
                                        (heroImgSrc, heroImgDst))

                # copy to preview file
                try:
                    file_utils.copy(heroImgSrc, heroPreview)
                    logger.debug('Copy to master %s - %s' %
                                 (heroImgSrc, heroPreview))
                    imgPublishes.append(heroPreview)

                except Exception as e:
                    errorMessage.append('Failed to copy to master %s-%s' %
                                        (heroImgSrc, heroPreview))

            # copy to heroMovSrc
            if heroMovSrc:
                movExt = os.path.splitext(heroMovSrc)[-1]
                heroMovDst = '%s/%s%s' % (mediaPath, publishName, movExt)
                try:
                    file_utils.copy(heroMovSrc, heroMovDst)
                    logger.debug('Copy to hero %s - %s' %
                                 (heroMovSrc, heroMovDst))
                    imgPublishes.append(heroMovDst)
                    info.set('primaryOutput', 'heroMovFile', heroMovDst)

                except Exception as e:
                    errorMessage.append('Failed to copy to hero %s-%s' %
                                        (heroMovSrc, heroMovDst))

            else:
                # if not media, use image as upload media
                info.set('primaryOutput', 'heroMovFile', str(heroImgDst))

    if errorMessage:
        return False, errorMessage

    else:
        return True, 'Success \n%s' % imgPublishes
Esempio n. 16
0
def publish_file(entity=None):
    """ publish work file """
    errorMessage = []

    if not entity:
        entity = path_info.PathInfo()

    if entity:
        logger.debug('start publishing ...')

        # get publish info
        publishFile, saveWorkFile, incrementSaveWorkFile, libFile = pub_utils.get_publish_info(
            entity)

        logger.debug('save work file %s' % saveWorkFile)
        logger.debug('publish version %s' % publishFile)
        logger.debug('save increment work file %s' % incrementSaveWorkFile)

        # start process files
        saveResult = None
        publishResult = None
        workResult = None

        # publish info
        pubEntity = path_info.PathInfo(publishFile)
        info = publish_info.TaskInfo(pubEntity)

        # save as
        saveResult = hook.save_file_as(incrementSaveWorkFile)
        info.set('work', 'incrementWorkFile', incrementSaveWorkFile)

        if saveResult:
            # copy to publish
            publishResult = file_utils.copy(saveResult, publishFile)
            info.set('primaryOutput', 'publishFile', publishFile)

            # copy to hero
            # disable. Not all department export to lib, move to dept publish
            # publishHeroResult = file_utils.copy(saveResult, libFile)
            # info.set('primaryOutput', 'heroFile', libFile)

            # copy to current work version (short cut for overwritten save)
            workResult = file_utils.copy(saveResult, saveWorkFile)
            info.set('work', 'workfile', saveWorkFile)

        if not saveResult:
            logger.error('Save to %s has failed' % incrementSaveWorkFile)
            errorMessage.append('Save to %s has failed' %
                                incrementSaveWorkFile)

        if not publishResult:
            logger.error('Publish to %s has failed' % publishFile)
            errorMessage.append('Publish to %s has failed' % publishFile)

        # if not publishHeroResult:
        # 	logger.error('Publish to hero %s has failed' % libFile)
        # 	errorMessage.append('Publish to %s has failed' % libFile)

        if not workResult:
            logger.error('Overwrite work version %s has failed' % saveWorkFile)
            errorMessage.append('Overwrite work version %s has failed' %
                                saveWorkFile)

    if errorMessage:
        return False, errorMessage

    else:
        return True, 'Success \n%s' % publishResult