コード例 #1
0
ファイル: publish.py プロジェクト: ChanonVilaiyuk/rftool
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
コード例 #2
0
def publish_version(entity=None, publishFile=None):
    """ create version in shotgun """
    userEntity = None
    message = str()
    processStatus = False

    # get publish info
    if not publishFile:
        if ui:
            publishFile = str(ui.publishVersionLabel.text())
            userEntity = ui.userWidget.read()

    if publishFile:
        pubEntity = path_info.PathInfo(publishFile)
        info = publish_info.TaskInfo(pubEntity)
        taskName = info.get('taskName', '')

        # create_version
        project = entity.project
        assetName = entity.name

        # find key data
        assetEntity = sg_process.get_one_asset(project, assetName)
        info.set('shotgun', 'asset_entity', assetEntity)

        projectEntity = assetEntity.get('project', None)
        info.set('shotgun', 'project_entity', projectEntity)

        taskEntity = sg_process.get_one_task(assetEntity, taskName)
        info.set('shotgun', 'task_entity', taskEntity)

        # if key data found
        if assetEntity and projectEntity and taskEntity:
            versionName = pubEntity.basename(ext=False)
            status = ui.statusWidget.get_task_status()
            description = ''
            playlistEntity = None
            result = sg_process.publish_version(projectEntity, assetEntity,
                                                taskEntity, userEntity,
                                                versionName, status,
                                                description, playlistEntity)

            message = 'Version creation not success'
            if result:
                info.set('shotgun', 'version_entity', result)
                processStatus = True
                message = 'Success %s' % result

        else:
            message = 'Data missing %s %s %s' % (assetEntity, projectEntity,
                                                 taskEntity)
            logger.warning(message)
            processStatus = False

    else:
        message = 'No Publish File input'
        logger.warning(message)
        processStatus = False

    return processStatus, message
コード例 #3
0
def upload_media(entity=None, publishFile=None):
    """ upload mov file to version """
    message = str()
    processStatus = False

    # get publish info
    if not publishFile:
        if ui:
            publishFile = str(ui.publishVersionLabel.text())

    if publishFile:
        pubEntity = path_info.PathInfo(publishFile)
        info = publish_info.TaskInfo(pubEntity)
        heroMovFile = info.get('primaryOutput', 'heroMovFile')
        versionEntity = info.get('shotgun', 'version_entity')

        if os.path.exists(heroMovFile) and versionEntity:
            uploadFile = heroMovFile.replace('/', '\\')
            result = sg_process.upload_version_media(versionEntity, uploadFile)

            if result:
                message = 'Success %s' % result
                processStatus = True

            else:
                message = 'Failed to upload movie'
                logger.warning(message)

        else:
            message = 'Path %s not exists or versionEntity %s not found' % (
                heroImgFile, versionEntity)
            logger.warning(message)

    return processStatus, message
コード例 #4
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'
コード例 #5
0
def list_polytag(): 
    meshes = mc.ls(type='mesh')
    info = dict()

    if meshes: 
        meshTransforms = [mc.listRelatives(a, p=True, f=True)[0] for a in meshes if mc.listRelatives(a, p=True)]
        
        for mesh in meshTransforms: 
            projectAttr = '%s.%s' % (mesh, 'project')
            assetAttr = '%s.%s' % (mesh, 'assetName')
            pathAttr = '%s.%s' % (mesh, 'path')

            if mc.objExists(projectAttr) and mc.objExists(assetAttr) and mc.objExists(pathAttr): 
                project = mc.getAttr(projectAttr)
                assetName = mc.getAttr(assetAttr)
                path = mc.getAttr(pathAttr)
                asset = path_info.PathInfo(path=path)

                if not assetName in info.keys(): 
                    info[assetName] = [asset, [mesh]]

                else: 
                    if not mesh in info[assetName][1]: 
                        info[assetName][1].append(mesh)

    return info
コード例 #6
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.'
    def get_info(self):
        self.model = path_info.PathInfo(self.thisScene)
        self.asset_name = self.model.name
        self.department = self.model.step
        self.version_name = self.model.versionNoUser
        self.version = file_utils.find_version(self.thisScene)
        self.task_name = self.model.task
        self.resolution = self.task_name.split('_')[-1]

        self.prod_dir = self.model.entityPath(root='RFPROD')
        self.pre_gpu = self.prod_dir + '/cache/' + '_'.join(
            [self.asset_name, 'gpu', self.resolution]) + '.abc'
        self.pre_abc = self.prod_dir + '/cache/' + '_'.join(
            [self.asset_name, 'abc', self.resolution]) + '.abc'
        self.src_publ = self.prod_dir + '/srcPublish/' + self.version_name + '.ma'

        self.publ_dir = self.model.entityPath(root='RFPUBL')
        self.publ_path = self.publ_dir + '/publish/' + '_'.join([
            self.asset_name, self.department, self.resolution, self.version
        ]) + '.ma'

        self.publ_lib = self.publ_dir + '/lib/' + '_'.join(
            [self.asset_name, self.department, self.resolution]) + '.ma'
        self.gpu_lib = self.publ_dir + '/lib/' + '_'.join(
            [self.asset_name, 'gpu', self.resolution]) + '.abc'
        self.abc_lib = self.publ_dir + '/lib/' + '_'.join(
            [self.asset_name, 'abc', self.resolution]) + '.abc'

        print self.publ_path
        print self.publ_lib
コード例 #8
0
def summarized_info(*args):
    """ write published info from Task to Asset info """
    # get publish info
    if ui:
        publishFile = str(ui.publishVersionLabel.text())
        pubEntity = path_info.PathInfo(publishFile)
        taskInfo = publish_info.TaskInfo(pubEntity)
        assetInfo = publish_info.AssetInfo(pubEntity)

        data = assetInfo.read()
        taskDict = dict()

        # set
        # asset id
        assetEntity = taskInfo.get('shotgun', 'asset_entity')
        data.update({'assetID': assetEntity.get('id')})

        # task id
        taskEntity = taskInfo.get('shotgun', 'task_entity')

        # publish file
        output = taskInfo.get('primaryOutput', 'publishFile')
        # hero file
        outputHero = taskInfo.get('primaryOutput', 'heroFile')

        # user
        versionEntity = taskInfo.get('shotgun', 'version_entity')
        user = str()
        if versionEntity:
            user = versionEntity.get('user', {}).get('name')

        # set dict
        taskDict = {
            pubEntity.taskName: {
                'id': taskEntity.get('id'),
                'output': output,
                'user': user
            },
            'output': output,
            'outputHero': outputHero,
            'user': user
        }

        # set department
        if pubEntity.step in data.keys():
            data[pubEntity.step].update(taskDict)

        else:
            data.update({pubEntity.step: taskDict})

        assetInfo.setData(data)
        result = assetInfo.publish()

        return True, 'Success \npublish info %s' % result

    else:
        logger.warning('No ui information')
        return False, 'No ui information'
コード例 #9
0
    def set_publish_version(self):
        """ set publish version based on source input """
        task = self.taskWidget.get_task()

        if task:
            logger.debug('set publish version')

            source = str(self.sourceFileWidget.widget.text())
            entity = path_info.PathInfo(source)
            entity.task = task.get('content')

            publishFile, saveWorkFile, incrementSaveWorkFile, libFile = pub_utils.get_publish_info(
                entity)
            self.publishVersionLabel.setText(publishFile)

            # set entity from source **
            self.pathInfo = path_info.PathInfo(source)

            logger.debug('version %s' % os.path.basename(publishFile))
コード例 #10
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'
コード例 #11
0
    def list_asset(self): 
        assetDict = self.get_assets()
        self.ui.tableWidget.blockSignals(True)

        ui_wrapper.clear_table(self.ui.tableWidget)
        project = str(self.ui.project_comboBox.currentText())
        step = str(self.ui.dept_comboBox.currentText())

        for row, value in assetDict.iteritems(): 
            baseColor = [255, 255, 255]
            assetColor = [255, 255, 255]

            if isMaya: 
                assetColor = [0, 0, 0]
                baseColor = [0, 0, 0]

            if value.get('duplicated'): 
                assetColor = [255, 200, 200]
                if isMaya: 
                    assetColor = [100, 0, 0]

            # asset 
            logger.debug(value.get('type'))
            logger.debug(value.get('subType'))
            logger.debug(value.get('asset'))
            asset = path_info.PathInfo(project=project, entity='asset', entitySub1=value.get('type'), entitySub2=value.get('subType'), name=value.get('asset'), step=step)

            ui_wrapper.insert_row(self.ui.tableWidget, row, height=20)
            ui_wrapper.fill_table(self.ui.tableWidget, row, self.columnName.index('Asset Name'), value.get('asset'), iconPath='', color=assetColor)
            ui_wrapper.fill_table(self.ui.tableWidget, row, self.columnName.index('Type'), value.get('type'), iconPath='', color=baseColor)
            ui_wrapper.fill_table(self.ui.tableWidget, row, self.columnName.index('SubType'), value.get('subType'), iconPath='', color=baseColor)
            ui_wrapper.fill_table(self.ui.tableWidget, row, self.columnName.index('Source'), '', iconPath='', color=baseColor)
            ui_wrapper.fill_table(self.ui.tableWidget, row, self.columnName.index('Status'), '', iconPath='', color=baseColor)

            # checkBox 
            checkBox = QtWidgets.QCheckBox()
            self.ui.tableWidget.setCellWidget(row, self.columnName.index('Select'), checkBox)

            # res comboBox 
            resComboBox = QtWidgets.QComboBox()
            resComboBox.addItems(self.res)
            resComboBox.setCurrentIndex(self.res.index(self.resDefault))
            self.ui.tableWidget.setCellWidget(row, self.columnName.index('res'), resComboBox)
            resComboBox.currentIndexChanged.connect(partial(self.set_dst_status, row, asset))

            # set file target status 
            self.set_dst_status(row, asset)

            # resize to fit contents 
            self.ui.tableWidget.resizeColumnToContents(self.columnName.index('Select'))
            self.ui.tableWidget.resizeColumnToContents(self.columnName.index('res'))
            self.ui.tableWidget.resizeColumnToContents(self.columnName.index('Target'))

        self.ui.tableWidget.blockSignals(False)
コード例 #12
0
ファイル: pub_utils.py プロジェクト: ChanonVilaiyuk/rftool
    def get_info(self):
        self.scene = path_info.PathInfo(self.thisScene)
        self.file_name = self.scene.versionName
        self.user = self.scene.user
        self.version_name = '_'.join(self.scene.fileUser.split('_')[:-1])
        self.version_num = file_utils.find_version(self.thisScene)

        self.prod_dir = self.scene.entityPath(root='RFPROD')
        self.prod_avi = self.prod_dir + '/movies/' + self.version_name + '.avi'
        self.prod_mov = self.prod_dir + '/movies/' + self.version_name + '.mov'
        self.prod_img = self.prod_dir + '/images/' + self.version_name + '.jpg'
コード例 #13
0
def auto_fill2(*args): 
    asset = path_info.PathInfo()
    if mc.objExists('Geo_Grp'): 
        plys = maya_utils.find_ply('Geo_Grp')

        for ply in plys: 
            mc.setAttr('%s.path' % ply, asset.path, type='string')
            mc.setAttr('%s.assetName' % ply, asset.name, type='string')
            mc.setAttr('%s.project' % ply, asset.project, type='string')

        if mc.objExists('Rig_Grp'): 
            add('Rig_Grp')
            copy_attr(plys[0], 'Rig_Grp')
コード例 #14
0
ファイル: sg_hook.py プロジェクト: ChanonVilaiyuk/rftool
	def __init__(self, path=None):
		super(SGEntity, self).__init__()

		self.pathInfo = None

		if type(path).__name__ == 'PathInfo':
			self.pathInfo = path
		elif type(path).__name__ == 'str':
			self.pathInfo = path_info.PathInfo(path)

		# cache
		self.cacheProject = None
		self.cacheEntity = None
		self.cacheTasks = None
コード例 #15
0
ファイル: misc.py プロジェクト: ChanonVilaiyuk/rftool
def list_asset():
    from rftool.utils import sg_process
    from rftool.utils import path_info
    res = 'md'
    fields = ['code', 'sg_asset_type', 'sg_subtype']
    sgassets = sg_process.sg.find(
        'Asset',
        [['project.Project.name', 'is', 'Two_Heroes'],
         ['sg_asset_type', 'is', 'setDress'], ['sg_subtype', 'is', 'garbage']],
        fields)

    for i, each in enumerate(sgassets):
        asset = path_info.PathInfo(project='Two_Heroes',
                                   entity='asset',
                                   entitySub1=each.get('sg_asset_type'),
                                   entitySub2=each.get('sg_subtype'),
                                   name=each.get('code'))
        libPath = asset.libPath()
        modelName = asset.libName(step='model', res=res, project=False)
        rigName = asset.libName(step='rig', res=res, project=False)

        modelPath = '%s/%s' % (libPath, modelName)
        rigPath = '%s/%s' % (libPath, rigName)
        print '=================='
        print '%s %s' % (i, libPath)

        if os.path.exists(modelPath):
            try:
                mc.file(modelPath, o=True, f=True, prompt=False)
            except Exception as e:
                print e
            clean_file()
            mc.file(rename=modelPath)
            mc.file(save=True, f=True)
        else:
            print 'missing %s' % modelPath

        if os.path.exists(rigPath):
            try:
                mc.file(rigPath, o=True, f=True, prompt=False)
            except Exception as e:
                print e
            clean_file()
            mc.file(rename=rigPath)
            mc.file(save=True, f=True)
        else:
            print 'missing %s' % rigPath

        print '========'
コード例 #16
0
    def get_asset_info(self, row): 
        project = str(self.ui.project_comboBox.currentText())
        step = str(self.ui.dept_comboBox.currentText())
        assetName = ui_wrapper.get_tableWidget_item(self.ui.tableWidget, row, self.columnName.index('Asset Name'), widget=False)
        assetType = ui_wrapper.get_tableWidget_item(self.ui.tableWidget, row, self.columnName.index('Type'), widget=False)
        subType = ui_wrapper.get_tableWidget_item(self.ui.tableWidget, row, self.columnName.index('SubType'), widget=False)
        source = ui_wrapper.get_tableWidget_item(self.ui.tableWidget, row, self.columnName.index('Source'), widget=False)
        status = ui_wrapper.get_tableWidget_item(self.ui.tableWidget, row, self.columnName.index('Status'), widget=False)
        resWidget = ui_wrapper.get_tableWidget_item(self.ui.tableWidget, row, self.columnName.index('res'), widget=True)
        res = str(resWidget.currentText())

        # {'project': 'project', 'entity'='asset', entitySub1='character', entitySub2='main', name='aiya', step=model, task='model_md'}
        asset = path_info.PathInfo(project=project, entity='asset', entitySub1=str(assetType.text()), entitySub2=str(subType.text()), name=str(assetName.text()), step=str(step))

        return {'asset': asset, 'source': str(source.text()), 'status': str(status.text()), 'res': res}
コード例 #17
0
ファイル: pub_utils.py プロジェクト: ChanonVilaiyuk/rftool
def get_publish_info(entity=None): 
    """ publish asset info """ 
    # normal steps 
    # save -> copy publish -> increment 
    # short steps, save only once to save time
    # save increment -> copy publish (v-1) -> copy 

    if not entity: 
        entity = path_info.PathInfo()

    sourceFile = entity.path 
    srcVersion = path_info.find_version(sourceFile)
    
    publishDir = entity.publishPath()
    publishName = entity.publishName(srcVersion, ext=True)
    publishFile = '{0}/{1}'.format(publishDir, publishName)

    saveWorkFile = sourceFile

    # condition 1 pub version exists 
    if os.path.exists(publishFile): 

        # find next available version 
        pubDirMax = path_info.find_next_version(path_info.listFile(publishDir))
        workDirMax = path_info.find_next_version(path_info.listFile(os.path.dirname(sourceFile)))

        # good both version
        if pubDirMax == workDirMax: 
            maxVersion = pubDirMax

        # user higher 
        else: 
            maxVersion = 'v%03d' % max(int(pubDirMax.replace('v', '')), int(workDirMax.replace('v', '')))

        publishFile = '{0}/{1}'.format(publishDir, entity.publishName(maxVersion, ext=True))
        saveWorkFile = path_info.replace_file_version(sourceFile, maxVersion)

    # increment
    pubVersion = path_info.find_version(publishFile)
    workIncrementVersion = 'v%03d' % (int(pubVersion.replace('v', '')) + 1)
    incrementSaveWorkFile = path_info.replace_file_version(sourceFile, workIncrementVersion)

    # hero 
    libPath = entity.libPath()
    libName = entity.libName(entity.step, entity.task_res(), ext=entity.ext)
    libFile = '{0}/{1}'.format(libPath, libName)

    return publishFile, saveWorkFile, incrementSaveWorkFile, libFile
コード例 #18
0
    def initial_UI(self):

        try:
            self.asset = path_info.PathInfo()
            self.this_path = self.asset.path
            self.project = self.asset.project
            self.version_name = self.asset.versionNoUser
            self.version = file_utils.find_version(self.this_path)
            self.type_name = self.asset.type
            self.subtype_name = self.asset.subtype
            self.asset_name = self.asset.name
            self.task_name = self.asset.taskName
            self.department = self.asset.step
            # self.user_name = self.scene.user
            self.src_pub_path = self.asset.entityPath(
                root='RFPUBL') + '/srcPublish/' + self.version_name
            # self.pub_path = self.asset.entityPath(root='RFPUBL') + '/srcPublish/' + self.version_name
            self.prod_dir = self.asset.entityPath(root='RFPROD')
            self.image_prod = self.asset.entityPath(
                root='RFPROD'
            ) + '/images/' + self.department + '/' + self.version_name
            self.image_publ = self.asset.entityPath(
                root='RFPUBL'
            ) + '/images/' + self.department + '/' + self.version_name
            self.image_path_no_ext = self.image_prod + '/' + self.version_name

            self.movie_prod = self.asset.entityPath(
                root='RFPROD'
            ) + '/movies/' + self.department + '/' + self.version_name
            self.movie_publ = self.asset.entityPath(
                root='RFPUBL'
            ) + '/movies/' + self.department + '/' + self.version_name

            self.thumbnail = ''
            self.movie = ''

            self.hide_progressBar()
            self.set_ui_information()
            self.get_thumbnail_version()
            self.get_sg_data()

        except AttributeError as attrErr:
            print attrErr, ',', self.this_path
            QtGui.QMessageBox.warning(self, 'Warning', 'No Maya Scene Open')
コード例 #19
0
def create_asset_template(root, project, assetType, assetSubType, assetName):
    scriptServer = os.environ['RFSCRIPT']
    templatePath = ''
    rootValid = False

    if root == config.RFPROJECT:
        steps = template.workAssetSteps
        templatePath = '%s/RFPROJECT' % template.templatePath
        rootValid = True

    if root == config.RFPUBL:
        steps = template.publAssetSteps
        templatePath = '%s/RFPUBL' % template.templatePath
        rootValid = True

    if root == config.RFPROD:
        steps = template.prodAssetSteps
        templatePath = '%s/RFPROD' % template.templatePath
        rootValid = True

    if rootValid:
        asset = path_info.PathInfo(project=project,
                                   entity=config.asset,
                                   entitySub1=assetType,
                                   entitySub2=assetSubType,
                                   name=assetName)
        assetPath = asset.entityPath(root)

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

        for step in steps:
            src = '%s/%s' % (templatePath, step)
            dst = '%s/%s' % (assetPath, step)

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

        create_standin(asset)
        repath_ad(asset)

        return True
コード例 #20
0
ファイル: check.py プロジェクト: ChanonVilaiyuk/rftool
def list_asset(project='Two_Heroes', assetTypes=['setDress']):
    listFilter = [["sg_asset_type", "is", a] for a in assetTypes]
    print listFilter
    advancedFilter = {"filter_operator": "any", "filters": listFilter}

    filters = [['project.Project.name', 'is', project], advancedFilter]
    fields = ['sg_asset_type', 'sg_subtype', 'code']
    result = sg_process.sg.find('Asset', filters, fields)
    assets = []

    for entity in result:
        asset = path_info.PathInfo(project=project,
                                   entity='asset',
                                   entitySub1=entity.get('sg_asset_type'),
                                   entitySub2=entity.get('sg_subtype'),
                                   name=entity.get('code'))
        assets.append(asset)

    return assets
コード例 #21
0
ファイル: misc.py プロジェクト: ChanonVilaiyuk/rftool
def quick_export():
    sels = mc.ls(sl=True)
    res = 'md'
    geoGrp = 'Geo_Grp'
    rigGrp = 'Rig_Grp'

    for obj in sels:
        assetName = str()
        libPath = str()

        assetAttr = '%s.assetName' % obj
        libAttr = '%s.path' % obj

        if mc.objExists(assetAttr):
            assetName = mc.getAttr(assetAttr)
        if mc.objExists(libAttr):
            libPath = mc.getAttr(libAttr)

        if assetName and libPath:
            asset = path_info.PathInfo(path=libPath)
            refPath = asset.libPath()
            rigName = asset.libName(step='rig', res=res, project=False)
            exportPath = '%s/%s' % (refPath, rigName)
            gpuName = os.path.splitext(
                asset.libName(step='gpu', res=res, project=False,
                              ext='abc'))[0]
            adName = asset.libName('', 'ad', project=False)
            modelName = asset.libName(step='model', res=res, project=False)

            print exportPath
            print refPath, gpuName
            print refPath, modelName

            sgResult = sg_process.create_asset(project=projectEntity,
                                               assetType=entitySub1,
                                               assetSubType=entitySub2,
                                               assetName=entityName,
                                               episode=episodeEntity,
                                               taskTemplate=taskTemplate)
            if sgResult:
                dirResult = pipeline_utils.create_asset_template(
                    root, projectEntity['name'], entitySub1, entitySub2,
                    entityName)
コード例 #22
0
    def get_scene_info(self):
        self.scene = path_info.PathInfo()
        self.this_path = self.scene.path
        self.project = self.scene.project
        self.version = file_utils.find_version(self.this_path)
        # self.version_name = self.scene.name +
        self.episode = self.scene.episode
        self.sequence = self.scene.sequence
        self.shot = self.scene.shot
        self.department = self.scene.step
        self.version_name = '_'.join(self.scene.fileUser.split('_')[:-1])
        self.user_name = self.scene.user

        self.prod_dir = self.scene.entityPath(root='RFPROD')
        self.prod_avi = self.prod_dir + '/movies/' + self.version_name + '.avi'
        self.prod_mov = self.prod_dir + '/movies/' + self.version_name + '.mov'
        self.prod_img = self.prod_dir + '/images/' + self.version_name + '.jpg'

        self.thumbnails = None
        self.movies = None
コード例 #23
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
コード例 #24
0
def create_scene_template(root, project, episodeName, sequenceName, shotName):
    scriptServer = os.environ['RFSCRIPT']
    templatePath = ''
    rootValid = False

    if root == config.RFPROJECT:
        steps = template.workSceneSteps
        templatePath = '%s/RFPROJECT' % template.templatePath
        rootValid = True

    if root == config.RFPUBL:
        steps = template.publSceneSteps
        templatePath = '%s/RFPUBL' % template.templatePath
        rootValid = True

    if root == config.RFPROD:
        steps = template.prodSceneSteps
        templatePath = '%s/RFPROD' % template.templatePath
        rootValid = True

    if rootValid:
        shot = path_info.PathInfo(project=project,
                                  entity=config.scene,
                                  entitySub1=episodeName,
                                  entitySub2=sequenceName,
                                  name=shotName)
        shotPath = shot.entityPath(root)

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

        for step in steps:
            src = '%s/%s' % (templatePath, step)
            dst = '%s/%s' % (shotPath, step)

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

        return True
コード例 #25
0
def set_task(entity=None, publishFile=None):
    """ change task status """
    message = str()
    processStatus = False

    # get publish info
    if not publishFile:
        if ui:
            publishFile = str(ui.publishVersionLabel.text())

    if publishFile:
        pubEntity = path_info.PathInfo(publishFile)
        info = publish_info.TaskInfo(pubEntity)
        taskEntity = info.get('shotgun', 'task_entity')
        taskName = info.get('taskName', '')

        # if no data in publish_info, query from shotgun
        if not taskEntity:
            logger.debug('taskEntity not found in publish_info')
            project = pubEntity.project
            assetName = pubEntity.name
            assetEntity = sg_process.get_one_asset(project, assetName)
            info.set('shotgun', 'asset_entity', assetEntity)

            taskEntity = sg_process.get_one_task(assetEntity, taskName)
            info.set('shotgun', 'task_entity', taskEntity)

        if taskEntity:
            status = ui.statusWidget.get_task_status()
            data = {'sg_status_list': status}
            result = sg_process.set_task_data(taskEntity.get('id'), data)
            processStatus = True
            message = 'Success %s' % result

        else:
            message = 'Failed to get taskEntity'

    return processStatus, message
コード例 #26
0
def auto_fill(*args): 
    from rftool.utils import sg_process
    sels = mc.ls(sl=True)
    caches = dict()
    if sels: 
        for ply in sels: 
            project = mc.getAttr('%s.project' % ply)
            assetName = mc.getAttr('%s.assetName' % ply)
            entity = caches.get(project, {}).get(assetName)

            if not entity: 
                entity = sg_process.sg.find_one('Asset', [['project.Project.name', 'is', project], ['code', 'is', assetName]], ['code', 'sg_asset_type', 'sg_subtype', 'id'])
                print entity
                if entity: 
                    if not project in caches.keys(): 
                        caches.update({project: {assetName: entity}})

            if entity: 
                asset = path_info.PathInfo(project=project, entity='asset', entitySub1=entity.get('sg_asset_type'), entitySub2=entity.get('sg_subtype'), name=assetName)
                libPath = asset.libPath()
                mc.setAttr('%s.id' % ply, entity.get('id'))
                mc.setAttr('%s.path' % ply, libPath, type='string')
                mc.rename(ply, assetName)
コード例 #27
0
ファイル: misc.py プロジェクト: ChanonVilaiyuk/rftool
def import_assets():
    from rftool.utils import sg_process
    from rftool.utils import path_info
    res = 'md'
    fields = ['code', 'sg_asset_type', 'sg_subtype']
    sgassets = sg_process.sg.find(
        'Asset',
        [['project.Project.name', 'is', 'Two_Heroes'],
         ['sg_asset_type', 'is', 'setDress'], ['sg_subtype', 'is', 'garbage']],
        fields)

    for i, each in enumerate(sgassets):
        asset = path_info.PathInfo(project='Two_Heroes',
                                   entity='asset',
                                   entitySub1=each.get('sg_asset_type'),
                                   entitySub2=each.get('sg_subtype'),
                                   name=each.get('code'))
        libPath = asset.libPath()
        modelName = asset.libName(step='model', res=res, project=False)
        rigName = asset.libName(step='rig', res=res, project=False)
        rigPath = '%s/%s' % (libPath, rigName)

        if os.path.exists(rigPath):
            mc.file(rigPath, i=True, ns=asset.name)
コード例 #28
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)
コード例 #29
0
    def __init__(self, parent=None):
        #Setup Window
        super(RFStillPublish, self).__init__(parent)

        # ui read
        uiFile = '%s/ui.ui' % moduleDir

        if isMaya:
            self.ui = load.loadUIMaya(uiFile, self)
        else:
            self.ui = load.loadUI(uiFile, self)
        self.ui.show()
        self.ui.setWindowTitle('RF Still Publish v.0.1.0')

        self.pathInfo = path_info.PathInfo()

        self.imageFormat = ['.jpg', '.png', '.jpeg']
        self.snapFormat = 'png'

        publish_core.ui = self

        self.set_ui()
        self.init_signals()
        self.init_functions()
コード例 #30
0
def switch(ply, level, srcPly=None): 
    assetAttr = '%s.%s' % (ply, 'assetName')
    pathAttr = '%s.%s' % (ply, 'path')
    assetDataAttr = '%s.%s' % (ply, 'assetData')
    parent = mc.listRelatives(ply, p=True)

    if mc.objExists(assetAttr) and mc.objExists(pathAttr): 
        assetName = mc.getAttr(assetAttr)
        path = mc.getAttr(pathAttr)
        data = eval(mc.getAttr(assetDataAttr))
        data.update({'original': path})
        asset = path_info.PathInfo(path=path)
        refPath = '%s/%s_%s.ma' % (asset.libPath(), asset.name, level)

        if os.path.exists(refPath): 
            assetPlc = place_asset(refPath, srcPly=srcPly)
            transfer_attr(ply, assetPlc, level)
            
            mc.delete(mc.parentConstraint(ply, assetPlc))
            mc.delete(ply)
            assetPlc = mc.rename(assetPlc, ply)
            mc.parent(assetPlc, parent)

            return assetPlc