def process(self, context):

        filename = os.path.basename(context.data('currentFile'))

        # version data
        try:
            (prefix, version) = pyblish_utils.version_get(filename, 'v')
        except:
            self.log.warning('Cannot publish workfile which is not versioned.')
            return

        context.data['version'] = version
        context.data['vprefix'] = prefix

        self.log.info('Scene Version: %s' % context.data('version'))
Пример #2
0
    def process(self, context):

        current_file = context.data('currentFile')
        directory, filename = os.path.split(str(current_file))

        if current_file.lower() in ['', '.', 'untitled', 'root']:
            self.log.warning('New scene! Preparing an initial workfile')
            # create instance
            instance = context.create_instance(name=filename)
            instance.data['family'] = 'new_scene'
            instance.data['path'] = ''
            version = 1
            prefix = 'v'

        else:
            # create instance
            instance = context.create_instance(name=filename)
            instance.data['family'] = 'scene'
            instance.data['path'] = current_file

            self.log.warning('Collected instance: {}'.format(instance))
            self.log.warning('Scene path: {}'.format(current_file))

            # ftrack data
            components = {}
            if pyblish.api.current_host() == 'nuke':
                components['nukescript'] = {'path': current_file}
            else:
                components['scene'] = {'path': current_file}

            instance.set_data('ftrackComponents', value=components)
            self.log.info("Added: %s" % components)

            if 'asset' in str(current_file):
                instance.set_data('ftrackAssetType', value='img')

            # version data
            try:
                (prefix, version) = pyblish_utils.version_get(filename, 'v')
            except:
                self.log.warning('Cannot publish workfile which is not versioned.')
                return

        context.data['version'] = version
        context.data['vprefix'] = prefix

        instance.add(current_file)
    def process(self, context, instance):

        if context.has_data("version"):

            sourcePath = context.data("currentFile")

            new_file = pyblish_utils.version_up(sourcePath)

            version = "".join(pyblish_utils.version_get(new_file, "v"))
            taskid = context.data("ftrackData")["Task"]["id"]

            ftrack_data = context.data["ftrackData"]
            if "Asset_Build" not in ftrack_data.keys():
                templates = ["shot.work.file"]
            else:
                templates = ["asset.work.file"]

            root = context.data("ftrackData")["Project"]["root"]
            self.log.debug(root)

            new_workFile = ft_pathUtils.getPathsYaml(taskid, templateList=templates, version=version, root=root)[0]

            #################################################################

            self.log.info(
                "New workfile version created: \
                            {}".format(
                    new_workFile
                )
            )
            self.log.info(
                "Next time you opens this task, \
                            start working on the version up file"
            )

            shutil.copy(sourcePath, new_workFile)
            context.set_data("versionUpFile", value=new_workFile)

        else:
            raise pyblish.api.ValidationError(
                "Can't find versioned up filename in context. \
                workfile probably doesn't have a version."
            )