Пример #1
0
    def checkAction(self,result):
        
        item = self.ui.thumbnail_listWidget.currentItem()
        asset_name = item.text()

        res_index = self.ui.lod_comboBox.currentIndex()
        res = self.ui.lod_comboBox.itemData(res_index,QtCore.Qt.UserRole)

        level_index = self.ui.level_comboBox.currentIndex()
        level = self.ui.level_comboBox.itemData(level_index,QtCore.Qt.UserRole)

        lib_dir = self.assets[asset_name]['lib']

        if result == 'create reference (default)':

            for lib in file_utils.listFile(lib_dir):
                if level in lib and res in lib:
                    lib_path = lib_dir + '/' + lib
                    break

            maya_utils.create_reference(asset_name, lib_path)

        if 'create' in result and '.ma' in result:
            file_name = result.split('create ')[-1]
            lib_path = lib_dir + '/' + file_name

            maya_utils.create_reference(asset_name, lib_path)

        if 'import' in result and '.ma' in result:
            file_name = result.split('import ')[-1]
            lib_path = lib_dir + '/' + file_name

            maya_utils.import_file(asset_name, lib_path)

        if 'open' in result and '.ma' in result:
            file_name = result.split('open ')[-1]
            lib_path = lib_dir + '/' + file_name

            maya_utils.open_file(lib_path)

        if result == 'create assembly':

            for lib in file_utils.listFile(lib_dir):
                if 'ad' in lib:
                    lib_path = lib_dir + '/' + lib
                    break
                    
            if lib_path:
                ar_node = maya_utils.create_asm_reference(asset_name,lib_path)

                for rep in asm_utils.listRepIndex(ar_node):
                    if res in rep:
                        asm_utils.setActiveRep(ar_node,rep)
                        break
Пример #2
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)
Пример #3
0
def repath_ad(asset):
    assetPath = asset.entityPath('RFPROJECT')
    refPath = '%s/%s' % (assetPath, config.ref)
    files = file_utils.listFile(refPath)
    adFile = asset.libName('', 'ad', project=False)
    replaceDict = {
        config.assemblyMap['assetName']: '%s_ad' % asset.name,
        config.assemblyMap['locatorLabel']: asset.name
    }

    if os.path.exists('%s/%s' % (refPath, adFile)):

        if files:
            for k, v in config.representationMap.iteritems():
                replaceFile = [a for a in files if k in a]

                if replaceFile:
                    path = '%s/%s' % (refPath, replaceFile[0])
                    replaceDict.update({v: path})

            logger.debug('replaceKey %s' % str(replaceDict))
            logger.info('repath ad complete %s' % ('%s/%s' %
                                                   (refPath, adFile)))
            return file_utils.search_replace_keys('%s/%s' % (refPath, adFile),
                                                  replaceDict,
                                                  backupFile=False)
Пример #4
0
    def get_media_info(self):
        self.thumbnails = [
            os.path.dirname(self.prod_img) + '/%s' % (n)
            for n in file_utils.listFile(os.path.dirname(self.prod_img))
            if self.version in n
        ]
        self.movies = [
            os.path.dirname(self.prod_avi) + '/%s' % (n)
            for n in file_utils.listFile(os.path.dirname(self.prod_avi))
            if self.version in n
        ]

        if not self.thumbnails == None and not self.movies == None:
            self.trace('Media Exists. Ready for submit/publish.')

        if self.sg_version and self.sg_version['sg_status_list'] == 'rev':
            self.ui.publish_pushButton.setStyleSheet(self.main_styleSheet)
            self.ui.publish_pushButton.setEnabled(True)
        if not self.sg_version or not self.sg_version[
                'sg_status_list'] == 'rev':
            self.ui.publish_pushButton.setStyleSheet(self.none_styleSheet)
            self.ui.publish_pushButton.setEnabled(False)
Пример #5
0
    def get_thumbnail_version(self):
        if os.path.exists(self.image_prod):
            media_list = file_utils.listFile(self.image_prod)
            if media_list:

                for media in media_list:
                    if media.split('.')[-1] in ['mov', 'avi', 'mp4']:
                        self.movie = self.asset.entityPath(
                            root='RFPROD') + '/movies/' + media_list
                        break

                        self.set_movie()

                if '.jpg' in media_list[-1]:
                    self.thumbnail = self.image_prod + '/' + media_list[-1]
                    self.set_thumbnail()
Пример #6
0
def create_standin(asset):
    assetPath = asset.entityPath('RFPROJECT')
    refPath = '%s/%s' % (assetPath, config.ref)
    files = file_utils.listFile(refPath)
    count = 0

    if files:
        for ref in files:
            if config.libFileReplaceKw in ref:
                newName = ref.replace(config.libFileReplaceKw, asset.name)
                src = '%s/%s' % (refPath, ref)
                dst = '%s/%s' % (refPath, newName)
                if not os.path.exists(dst):
                    os.rename(src, dst)
                    logger.debug('Renaming %s -> %s' % (src, dst))
                    count += 1
                else:
                    logger.debug('File exists. Cannot rename %s' % dst)

    logger.info('renaming %s files standin complete (%s)' % (count, refPath))
Пример #7
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
Пример #8
0
    def actionMenu(self,event):

        ref_menu = QtWidgets.QMenu(self.ui.thumbnail_listWidget)

        item = self.ui.thumbnail_listWidget.currentItem()
        asset_name = item.text()

        lib_dir = self.assets[asset_name]['lib']
        lib_files = file_utils.listFile(lib_dir)

        default_action = QtWidgets.QAction('create reference (default)',self.ui.thumbnail_listWidget)
        create_menu = QtWidgets.QMenu('create reference...',self.ui.thumbnail_listWidget)
        import_menu = QtWidgets.QMenu('import reference...',self.ui.thumbnail_listWidget)
        open_menu = QtWidgets.QMenu('open file...',self.ui.thumbnail_listWidget)
        asm_action = QtWidgets.QAction('create assembly',self.ui.thumbnail_listWidget)

        for lib in lib_files:
            if '.ma' in lib and not 'ad' in lib:
                create_action = QtWidgets.QAction('create %s' %lib, self.ui.thumbnail_listWidget)
                import_action = QtWidgets.QAction('import %s' %lib, self.ui.thumbnail_listWidget)
                open_action = QtWidgets.QAction('open %s' %lib, self.ui.thumbnail_listWidget)
                create_menu.addAction(create_action)
                import_menu.addAction(import_action)
                open_menu.addAction(open_action)

        ref_menu.addAction(default_action)
        ref_menu.addSeparator()
        ref_menu.addMenu(create_menu)
        ref_menu.addMenu(import_menu)
        ref_menu.addMenu(open_menu)
        ref_menu.addAction(asm_action)

        ref_menu.popup(self.ui.thumbnail_listWidget.mapToGlobal(event))
        result = ref_menu.exec_(self.ui.thumbnail_listWidget.mapToGlobal(event))

        if result:
            self.checkAction(result.text())
Пример #9
0
    def incrementFile(self): 
        dataPath = self.entity.dataPath()
        version = file_utils.find_next_version(file_utils.listFile(dataPath))
        versionData = self.entity.dataFile(version)

        return versionData