def process(self, instance):
        import pipeline_schema
        import pyblish_standalone

        # getting current work file
        work_path = pyblish_standalone.kwargs['path'][0].replace('\\', '/')
        work_path = work_path.lower()

        # get version data
        version = 1
        if instance.context.has_data('version'):
            version = instance.context.data('version')

        # expected path
        data = pipeline_schema.get_data()
        data['version'] = version
        data['extension'] = 'scn'
        file_path = pipeline_schema.get_path('task_work', data)
        """
        # if the path is completely invalid,
        # we need to find the next non-existing version to validate
        if file_path.split('v')[0] != work_path.split('v')[0]:
            self.log.info("Invalid path found.")
            file_path = utils.next_nonexisting_version(file_path)
        """

        # validating scene work path
        msg = 'Scene path is not correct:'
        msg += '\n\nCurrent: %s' % (work_path)
        msg += '\n\nExpected: %s' % (file_path)

        assert file_path == work_path, msg
Ejemplo n.º 2
0
    def process(self, instance):
        import pipeline_schema

        # skipping instance if data is missing
        if "deadlineData" not in instance.data:
            msg = "No deadlineData present. Skipping \"%s\"" % instance
            self.log.info(msg)
            return

        # skipping instance if the required data is missing
        if "movie" not in instance.data:
            msg = "Missing movie data."
            self.log.info(msg)
            return

        # setting ffmpeg settings
        extra_info_key_value = {}
        job_data = instance.data["deadlineData"]["job"]
        fps = instance.data["movie"]["fps"]
        first_frame = instance.data["movie"]["first_frame"]
        audio = instance.data["movie"]["audio"]

        if "ExtraInfoKeyValue" in job_data:
            extra_info_key_value = job_data["ExtraInfoKeyValue"]

        args = "-q:v 0 -pix_fmt yuv420p -vf scale=trunc(iw/2)*2:trunc(ih/2)*2"
        args += ",colormatrix=bt601:bt709"
        args += " -timecode %s" % self.frames_to_timecode(first_frame, fps)
        extra_info_key_value["FFMPEGOutputArgs0"] = args

        args = "-gamma 2.2 -framerate %s -start_number %s" % (fps, first_frame)
        extra_info_key_value["FFMPEGInputArgs0"] = args

        input_file = job_data["OutputFilename0"].replace("####", "%04d")
        args = input_file
        if audio:
            args += " -i " + audio.replace("\\", "/")
        extra_info_key_value["FFMPEGInput0"] = args

        # get version data
        version = 1
        if instance.context.has_data("version"):
            version = instance.context.data("version")

        # expected path
        data = pipeline_schema.get_data()
        data["version"] = version
        data["extension"] = "mov"
        data["output_type"] = "mov"
        data["name"] = instance.data["name"]
        output_file = pipeline_schema.get_path("output_file", data)

        extra_info_key_value["FFMPEGOutput0"] = output_file

        job_data["ExtraInfoKeyValue"] = extra_info_key_value
def callback(event):
    """ This plugin sets the task status from the version status update.
    """

    for entity in event["data"].get("entities", []):

        # Filter non-assetversions
        if entity.get("entityType") == "task" and entity["action"] in ["add", "move"]:

            data = pipeline_schema.get_data(entity.get("entityId"))
            data["extension"] = "temp"
            path = pipeline_schema.get_path("task_work", data)

            # create source folder
            src_dir = os.path.join(os.path.dirname(path), "source")
            if not os.path.exists(src_dir):
                os.makedirs(src_dir)
                print "Creating folder: %s" % src_dir
Ejemplo n.º 4
0
    def process(self, context, plugin):

        # expected path
        data = pipeline_schema.get_data()
        data["extension"] = "aep"

        version = 1
        if context.has_data("version"):
            version = context.data("version")
        data["version"] = version

        file_path = pipeline_schema.get_path("task_work", data)

        if not os.path.exists(os.path.dirname(file_path)):
            os.makedirs(os.path.dirname(file_path))

        cmd = "app.project.save(File(\"{0}\"))".format(file_path)
        pyblish_aftereffects.send(cmd)
Ejemplo n.º 5
0
    def process(self, instance):

        # getting current work file
        work_path = instance.data["workPath"].lower()

        # expected path
        data = pipeline_schema.get_data()
        data["extension"] = "aep"

        version = 1
        if instance.context.has_data("version"):
            version = instance.context.data("version")
        data["version"] = version

        file_path = pipeline_schema.get_path("task_work", data)

        # validating scene work path
        msg = "Scene path is not correct:"
        msg += "\n\nCurrent: %s" % (work_path)
        msg += "\n\nExpected: %s" % (file_path)

        assert file_path == work_path, msg
    def process(self, context, plugin):
        import os

        import pipeline_schema
        import pyblish_aftereffects

        # expected path
        data = pipeline_schema.get_data()
        data["extension"] = "aep"

        version = 1
        if context.has_data("version"):
            version = context.data("version")
        data["version"] = version

        file_path = pipeline_schema.get_path("task_work", data)

        if not os.path.exists(os.path.dirname(file_path)):
            os.makedirs(os.path.dirname(file_path))

        cmd = "app.project.save(File(\"{0}\"))".format(file_path)
        pyblish_aftereffects.send(cmd)
    def process(self, context, plugin):
        import os
        import shutil

        import pyblish_standalone
        from pyblish_bumpybox.plugins import utils
        import pipeline_schema

        # get version data
        version = 1
        if context.has_data('version'):
            version = context.data('version')

        # expected path
        data = pipeline_schema.get_data()
        data['version'] = version
        data['extension'] = 'scn'
        expected_path = pipeline_schema.get_path('task_work', data)

        # saving scene, if current directory is the same as the expected its
        # safe to assume to overwrite scene file
        current = context.data["currentFile"].replace("\\", "/")
        file_path = expected_path
        if os.path.dirname(expected_path) != os.path.dirname(current):
            file_path = utils.next_nonexisting_version(expected_path)

        file_dir = os.path.dirname(file_path)

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

        src = pyblish_standalone.kwargs['path'][0]

        shutil.copy(src, file_path)

        pyblish_standalone.kwargs['path'] = [file_path]

        self.log.info("Saved to \"%s\"" % file_path)
    def process(self, instance):
        import pipeline_schema

        # getting current work file
        work_path = instance.data["workPath"].lower()

        # expected path
        data = pipeline_schema.get_data()
        data["extension"] = "aep"

        version = 1
        if instance.context.has_data("version"):
            version = instance.context.data("version")
        data["version"] = version

        file_path = pipeline_schema.get_path("task_work", data)

        # validating scene work path
        msg = "Scene path is not correct:"
        msg += "\n\nCurrent: %s" % (work_path)
        msg += "\n\nExpected: %s" % (file_path)

        assert file_path == work_path, msg
Ejemplo n.º 9
0
    def process(self, instance):
        import os

        import pyblish_standalone
        import pipeline_schema

        job_data = {}
        plugin_data = {}
        if "deadlineData" in instance.data:
            job_data = instance.data["deadlineData"]["job"].copy()
            plugin_data = instance.data["deadlineData"]["plugin"].copy()

        job_data['Name'] = instance.data["name"]
        job_data['Frames'] = '%s-%s' % (instance.data('start'),
                                        instance.data('end'))
        job_data['ChunkSize'] = 10
        job_data['Group'] = 'celaction'
        job_data['Pool'] = 'medium'
        job_data['Plugin'] = 'CelAction'

        name = os.path.basename(instance.context.data["currentFile"])
        name = os.path.splitext(name)[0] + " - " + instance.data["name"]
        job_data["Name"] = name

        # get version data
        version = 1
        if instance.context.has_data('version'):
            version = instance.context.data('version')

        # get output filename
        data = pipeline_schema.get_data()
        data['extension'] = 'png'
        data['output_type'] = 'img'
        data['name'] = instance.data["name"]
        data['version'] = version
        output_path = pipeline_schema.get_path('output_sequence', data)
        job_data['OutputFilename0'] = output_path.replace('%04d', '####')

        # plugin data
        render_name_separator = '.'
        path = os.path.dirname(pyblish_standalone.kwargs['path'][0])
        filename = os.path.basename(pyblish_standalone.kwargs['path'][0])
        args = '<QUOTE>%s<QUOTE>' % os.path.join(path, 'publish', filename)
        args += ' -a'

        # not rendering a movie if outputting levels
        # also changing the RenderNameSeparator for better naming
        # ei. "levels.v001_1sky.0001.png" > "levels_1sky.v001.0001.png"
        if instance.has_data('levelSplit'):
            args += ' -l'
            instance.data.pop("movie", None)

            version_string = pipeline_schema.get_path('version', data)
            output_path = output_path.replace('.' + version_string, '')
            job_data['OutputFilename0'] = output_path.replace('%04d', '####')

            render_name_separator = '.%s.' % version_string

        args += ' -s <STARTFRAME>'
        args += ' -e <ENDFRAME>'
        args += ' -d <QUOTE>%s<QUOTE>' % os.path.dirname(output_path)
        args += ' -x %s' % instance.data('x')
        args += ' -y %s' % instance.data('y')
        args += ' -r <QUOTE>%s<QUOTE>' % output_path.replace('.%04d', '')
        args += ' -= AbsoluteFrameNumber=on -= PadDigits=4'
        args += ' -= ClearAttachment=on'

        plugin_data['Arguments'] = args

        plugin_data['StartupDirectory'] = ''
        plugin_data['RenderNameSeparator'] = render_name_separator

        # adding to instance
        data = {'job': job_data, 'plugin': plugin_data}
        instance.set_data('deadlineData', value=data)

        # creating output path
        if not os.path.exists(os.path.dirname(output_path)):
            os.makedirs(os.path.dirname(output_path))

        # ftrack data
        components = {instance.data["name"]: {'path': output_path}}
        instance.set_data('ftrackComponents', value=components)
    def process(self, instance):
        import os
        import _winreg
        import subprocess

        import pyblish_standalone
        import pipeline_schema
        import ftrack

        progpath = instance.context.data['kwargs']['data']['progpath'][:-1]
        exe = os.path.join(progpath, 'CelAction2D.exe')

        path = os.path.dirname(pyblish_standalone.kwargs['path'][0])
        filename = os.path.basename(pyblish_standalone.kwargs['path'][0])
        scene_file = os.path.join(path, 'publish', filename).replace('\\', '/')

        # getting submission parameters
        start = instance.context.data['kwargs']['data']['start']
        end = instance.context.data['kwargs']['data']['end']
        width = instance.context.data['kwargs']['data']['x']
        height = instance.context.data['kwargs']['data']['y']

        # get version data
        version_number = 1
        if instance.context.has_data('version'):
            version_number = instance.context.data('version')

        # get output filename
        data = pipeline_schema.get_data()
        data['extension'] = 'png'
        data['output_type'] = 'img'
        data['name'] = instance.data["name"]
        data['version'] = version_number
        output_path = pipeline_schema.get_path('output_sequence', data)

        # Modify registry for frame separation
        path = r'Software\CelAction\CelAction2D\User Settings'
        _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, path)
        hKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, path, 0,
                               _winreg.KEY_ALL_ACCESS)

        _winreg.SetValueEx(hKey, 'RenderNameUseSeparator', 0,
                           _winreg.REG_DWORD, 1)
        _winreg.SetValueEx(hKey, 'RenderNameSeparator', 0, _winreg.REG_SZ,
                           '.')

        # create output directory
        if not os.path.exists(os.path.dirname(output_path)):
            os.makedirs(os.path.dirname(output_path))

        # process render
        args = [exe, scene_file, '-a', '-s', start, '-e', end, '-x', width,
                '-y', height, '-d', os.path.dirname(output_path),
                '-r', os.path.basename(output_path).replace('.%04d', ''),
                '-=', 'AbsoluteFrameNumber=on', '-=', 'PadDigits=4',
                '-=', 'ClearAttachment=on']

        self.log.info('Arguments to execute: %s' % args)
        subprocess.call(args)

        # publish to ftrack
        task = ftrack.Task(instance.context.data['ftrackData']['Task']['id'])
        asset = task.getParent().createAsset(task.getName(), 'img', task=task)

        version = None
        for v in asset.getVersions():
            if v.getVersion() == version_number:
                version = v

        if not version:
            version = asset.createVersion()
            version.set('version', version_number)

        version.publish()

        try:
            version.createComponent(name=instance.data["name"], path=output_path)
        except:
            msg = 'Ftrack component "%s" already exists' % instance.data["name"]
            self.log.warning(msg)
    def process(self, instance):
        import os
        import subprocess

        import pipeline_schema
        import ftrack

        exe = 'ffmpeg.exe'

        # getting submission parameters
        start = instance.context.data['kwargs']['data']['start']

        # get version data
        version_number = 1
        if instance.context.has_data('version'):
            version_number = instance.context.data('version')

        # get input images
        data = pipeline_schema.get_data()
        data['extension'] = 'png'
        data['output_type'] = 'img'
        data['name'] = instance.data["name"]
        data['version'] = version_number
        image_files = pipeline_schema.get_path('output_sequence', data)

        # get output file
        data = pipeline_schema.get_data()
        data['version'] = version_number
        data['extension'] = 'mov'
        data['output_type'] = 'mov'
        data['name'] = instance.data["name"]
        output_path = pipeline_schema.get_path('output_file', data)

        # get audio file
        task = ftrack.Task(instance.context.data['ftrackData']['Task']['id'])
        audio_file = ''
        try:
            asset = task.getParent().getAsset('audio', 'audio')
            component = asset.getVersions()[-1].getComponent()
            audio_file = component.getFilesystemPath()
        except:
            self.log.warning("Couldn't find any audio file on Ftrack.")

        # create output directory
        if not os.path.exists(os.path.dirname(output_path)):
            os.makedirs(os.path.dirname(output_path))

        # process render
        args = [exe, '-gamma', '2.2', '-framerate', '25',
                '-start_number', start, '-i', image_files]

        if os.path.exists(audio_file):
            args.extend(['-i', audio_file])

        vf = 'scale=trunc(iw/2)*2:trunc(ih/2)*2,colormatrix=bt601:bt709'
        args.extend(['-q:v', '0', '-pix_fmt', 'yuv420p', '-vf', vf,
                     '-timecode', self.frames_to_timecode(int(start), 25),
                     '-y', output_path])

        self.log.info('Arguments to execute: %s' % args)
        subprocess.call(args)

        # publish to ftrack
        task = ftrack.Task(instance.context.data['ftrackData']['Task']['id'])
        asset = task.getParent().createAsset(task.getName(), 'mov', task=task)

        version = None
        for v in asset.getVersions():
            if v.getVersion() == version_number:
                version = v

        if not version:
            version = asset.createVersion()
            version.set('version', version_number)

        version.publish()

        try:
            version.createComponent(name=instance.data["name"], path=output_path)
        except:
            msg = 'Ftrack component "%s" already exists' % instance.data["name"]
            self.log.warning(msg)
Ejemplo n.º 12
0
    def process(self, instance):
        import os
        import re
        import shutil

        import pipeline_schema

        if "outputPaths" not in instance.data:
            return

        data = pipeline_schema.get_data()
        ext = os.path.splitext(instance.data["family"])[1].replace("_", ".")
        data["extension"] = ext[1:]

        pattern = r"\.[0-9]{4}\."
        components = {}
        for path in instance.data["outputPaths"]:

            if ".%04d." in path:
                data["output_type"] = "img"
                name = instance.data["name"]

                if instance.data["name"] == "levels":
                    current_file = instance.context.data["currentFile"]
                    current_file = os.path.basename(current_file)
                    pattern = current_file.replace(".scn",
                                                   r"_([0-9]{2}).*\.png")
                    level = re.match(pattern, path).group(1)
                    name = "levels_" + str(level)

                data["name"] = name
                images_path = pipeline_schema.get_path("output_sequence",
                                                       data=data)
                # ensuring parent path exists
                parent_path = os.path.dirname(images_path)
                if not os.path.exists(parent_path):
                    os.makedirs(parent_path)

                components[name] = {"path": images_path}

                for f in instance.data["outputPaths"][path]:
                    basename = os.path.basename(f)
                    frame = int(re.findall(r"\.[0-9]{4}\.", basename)[0][1:-1])
                    dst = images_path % frame

                    shutil.copy(f, dst)

                    # delete output
                    os.remove(f)

                    self.log.info("Moved {0} to {1}".format(f, dst))
            else:
                data["output_type"] = "mov"
                data["extension"] = "mov"
                movie_path = pipeline_schema.get_path("output_file", data=data)

                # ensuring parent path exists
                parent_path = os.path.dirname(movie_path)
                if not os.path.exists(parent_path):
                    os.makedirs(parent_path)

                components[instance.data["name"]] = {"path": movie_path}

                shutil.copy(path, movie_path)

                # delete output
                os.remove(path)

                self.log.info("Moved {0} to {1}".format(path, movie_path))

        instance.data["ftrackComponents"] = components
    def process(self, instance):
        import os
        import _winreg
        import subprocess

        import pyblish_standalone
        import pipeline_schema
        import ftrack

        progpath = instance.context.data['kwargs']['data']['progpath'][:-1]
        exe = os.path.join(progpath, 'CelAction2D.exe')

        path = os.path.dirname(pyblish_standalone.kwargs['path'][0])
        filename = os.path.basename(pyblish_standalone.kwargs['path'][0])
        scene_file = os.path.join(path, 'publish', filename).replace('\\', '/')

        # getting submission parameters
        start = instance.context.data['kwargs']['data']['start']
        end = instance.context.data['kwargs']['data']['end']
        width = instance.context.data['kwargs']['data']['x']
        height = instance.context.data['kwargs']['data']['y']

        # get version data
        version_number = 1
        if instance.context.has_data('version'):
            version_number = instance.context.data('version')

        # get output filename
        data = pipeline_schema.get_data()
        data['extension'] = 'png'
        data['output_type'] = 'img'
        data['name'] = instance.data["name"]
        data['version'] = version_number
        output_path = pipeline_schema.get_path('output_sequence', data)

        # Modify registry for frame separation
        path = r'Software\CelAction\CelAction2D\User Settings'
        _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, path)
        hKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, path, 0,
                               _winreg.KEY_ALL_ACCESS)

        _winreg.SetValueEx(hKey, 'RenderNameUseSeparator', 0,
                           _winreg.REG_DWORD, 1)
        _winreg.SetValueEx(hKey, 'RenderNameSeparator', 0, _winreg.REG_SZ, '.')

        # create output directory
        if not os.path.exists(os.path.dirname(output_path)):
            os.makedirs(os.path.dirname(output_path))

        # process render
        args = [
            exe, scene_file, '-a', '-s', start, '-e', end, '-x', width, '-y',
            height, '-d',
            os.path.dirname(output_path), '-r',
            os.path.basename(output_path).replace('.%04d', ''), '-=',
            'AbsoluteFrameNumber=on', '-=', 'PadDigits=4', '-=',
            'ClearAttachment=on'
        ]

        self.log.info('Arguments to execute: %s' % args)
        subprocess.call(args)

        # publish to ftrack
        task = ftrack.Task(instance.context.data['ftrackData']['Task']['id'])
        asset = task.getParent().createAsset(task.getName(), 'img', task=task)

        version = None
        for v in asset.getVersions():
            if v.getVersion() == version_number:
                version = v

        if not version:
            version = asset.createVersion()
            version.set('version', version_number)

        version.publish()

        try:
            version.createComponent(name=instance.data["name"],
                                    path=output_path)
        except:
            msg = 'Ftrack component "%s" already exists' % instance.data["name"]
            self.log.warning(msg)
    def process(self, instance):
        import os
        import subprocess

        import pipeline_schema
        import ftrack

        exe = 'ffmpeg.exe'

        # getting submission parameters
        start = instance.context.data['kwargs']['data']['start']

        # get version data
        version_number = 1
        if instance.context.has_data('version'):
            version_number = instance.context.data('version')

        # get input images
        data = pipeline_schema.get_data()
        data['extension'] = 'png'
        data['output_type'] = 'img'
        data['name'] = instance.data["name"]
        data['version'] = version_number
        image_files = pipeline_schema.get_path('output_sequence', data)

        # get output file
        data = pipeline_schema.get_data()
        data['version'] = version_number
        data['extension'] = 'mov'
        data['output_type'] = 'mov'
        data['name'] = instance.data["name"]
        output_path = pipeline_schema.get_path('output_file', data)

        # get audio file
        task = ftrack.Task(instance.context.data['ftrackData']['Task']['id'])
        audio_file = ''
        try:
            asset = task.getParent().getAsset('audio', 'audio')
            component = asset.getVersions()[-1].getComponent()
            audio_file = component.getFilesystemPath()
        except:
            self.log.warning("Couldn't find any audio file on Ftrack.")

        # create output directory
        if not os.path.exists(os.path.dirname(output_path)):
            os.makedirs(os.path.dirname(output_path))

        # process render
        args = [
            exe, '-gamma', '2.2', '-framerate', '25', '-start_number', start,
            '-i', image_files
        ]

        if os.path.exists(audio_file):
            args.extend(['-i', audio_file])

        vf = 'scale=trunc(iw/2)*2:trunc(ih/2)*2,colormatrix=bt601:bt709'
        args.extend([
            '-q:v', '0', '-pix_fmt', 'yuv420p', '-vf', vf, '-timecode',
            self.frames_to_timecode(int(start), 25), '-y', output_path
        ])

        self.log.info('Arguments to execute: %s' % args)
        subprocess.call(args)

        # publish to ftrack
        task = ftrack.Task(instance.context.data['ftrackData']['Task']['id'])
        asset = task.getParent().createAsset(task.getName(), 'mov', task=task)

        version = None
        for v in asset.getVersions():
            if v.getVersion() == version_number:
                version = v

        if not version:
            version = asset.createVersion()
            version.set('version', version_number)

        version.publish()

        try:
            version.createComponent(name=instance.data["name"],
                                    path=output_path)
        except:
            msg = 'Ftrack component "%s" already exists' % instance.data["name"]
            self.log.warning(msg)