示例#1
0
    def test_uncompress_is_working_properly_5(self):
        """testing if uncompress is working properly
        """
        seq5 = uncompress('a.%03d.tga 1-14 [1-14]', fmt='%h%p%t %r %R')
        self.assertEqual('a.1-14.tga', str(seq5))

        self.assertEqual(14, len(seq5))
示例#2
0
    def test_uncompress_is_working_properly_6(self):
        """testing if uncompress is working properly
        """
        seq6 = uncompress('a.%03d.tga 1-14 ([1-14])', fmt='%h%p%t %r (%R)')
        self.assertEqual('a.1-14.tga', str(seq6))

        self.assertEqual(14, len(seq6))
示例#3
0
    def process(self, instance):

        seq = pyseq.uncompress(instance.data('path'))
        for f in seq:
            self.log.info(f)

        assert False, 'stop'
示例#4
0
    def test_uncompress_is_working_properly_8(self):
        """testing if uncompress is working properly
        """
        seq8 = uncompress('a.%03d.tga 1-100 ([10, 20, 40, 50])',
                          fmt='%h%p%t %r (%m)')
        self.assertEqual('a.1-100.tga', str(seq8))

        self.assertEqual(96, len(seq8))
示例#5
0
    def test_uncompress_is_working_properly_2(self):
        """testing if uncompress is working properly
        """
        seq2 = uncompress('./tests/files/a.%03d.tga [1-3, 10, 12-14]',
                          fmt='%h%p%t %R')
        self.assertEqual('a.1-14.tga', str(seq2))

        self.assertEqual(7, len(seq2))
示例#6
0
    def test_uncompress_is_working_properly_1(self):
        """testing if uncompress is working properly
        """
        seq = uncompress('./tests/files/012_vb_110_v001.%04d.png 1-10',
                         fmt='%h%p%t %r')
        self.assertEqual('012_vb_110_v001.1-10.png', str(seq))

        self.assertEqual(10, len(seq))
示例#7
0
    def test_uncompress_is_working_properly_7(self):
        """testing if uncompress is working properly
        """
        seq7 = uncompress('a.%03d.tga 1-100000 ([1-10, 100000])',
                          fmt='%h%p%t %r (%R)')
        self.assertEqual('a.1-100000.tga', str(seq7))

        self.assertEqual(11, len(seq7))
示例#8
0
    def test_uncompress_is_working_properly_7(self):
        """testing if uncompress is working properly,
        the frame 100000 does not fit inside the pad length
        """
        seq7 = uncompress('a.%03d.tga 1-100000 ([1-10, 100000])',
                          fmt='%h%p%t %r (%R)')
        self.assertEqual('a.1-10.tga', str(seq7))

        self.assertEqual(10, len(seq7))
示例#9
0
 def test_uncompress_is_working_properly_4(self):
     """testing if uncompress is working properly
     """
     seq4 = uncompress(
         'a.%03d.tga 1-14 ([1-3, 10, 12-14])',
         fmt='%h%p%t %s-%e (%R)'
     )
     self.assertEqual(
         'a.1-14.tga',
         str(seq4)
     )
示例#10
0
 def test_uncompress_is_working_properly_4(self):
     """testing if uncompress is working properly
     """
     seq4 = uncompress(
         'a.%03d.tga 1-14 ([1-3, 10, 12-14])',
         fmt='%h%p%t %s-%e (%R)'
     )
     self.assertEqual(
         'a.1-14.tga',
         str(seq4)
     )
示例#11
0
    def test_uncompress_is_working_properly_5(self):
        """testing if uncompress is working properly
        """
        seq5 = uncompress('a.%03d.tga 1-14 [1-14]', fmt='%h%p%t %r %R')
        self.assertEqual(
            'a.1-14.tga',
            str(seq5)
        )

        self.assertEqual(
            14,
            len(seq5)
        )
示例#12
0
    def test_uncompress_is_working_properly_1(self):
        """testing if uncompress is working properly
        """
        seq = uncompress(
            './tests/files/012_vb_110_v001.%04d.png 1-10',
            fmt='%h%p%t %r'
        )
        self.assertEqual(
            '012_vb_110_v001.1-10.png',
            str(seq)
        )

        self.assertEqual(10, len(seq))
示例#13
0
    def test_uncompress_is_working_properly_6(self):
        """testing if uncompress is working properly
        """
        seq6 = uncompress('a.%03d.tga 1-14 ([1-14])', fmt='%h%p%t %r (%R)')
        self.assertEqual(
            'a.1-14.tga',
            str(seq6)
        )

        self.assertEqual(
            14,
            len(seq6)
        )
示例#14
0
    def test_uncompress_is_working_properly_2(self):
        """testing if uncompress is working properly
        """
        seq2 = uncompress(
            './tests/files/a.%03d.tga [1-3, 10, 12-14]',
            fmt='%h%p%t %R'
        )
        self.assertEqual(
            'a.1-14.tga',
            str(seq2)
        )

        self.assertEqual(
            7,
            len(seq2)
        )
示例#15
0
    def test_uncompress_is_working_properly_3(self):
        """testing if uncompress is working properly
        """
        seq3 = uncompress(
            'a.%03d.tga 1-14 (1-3 10 12-14)',
            fmt='%h%p%t %r (%R)'
        )
        self.assertEqual(
            'a.1-14.tga',
            str(seq3)
        )

        self.assertEqual(
            7,
            len(seq3)
        )
示例#16
0
    def test_uncompress_is_working_properly_8(self):
        """testing if uncompress is working properly
        """
        seq8 = uncompress(
            'a.%03d.tga 1-100 ([10, 20, 40, 50])',
            fmt='%h%p%t %r (%m)'
        )
        self.assertEqual(
            'a.1-100.tga',
            str(seq8)
        )

        self.assertEqual(
            96,
            len(seq8)
        )
示例#17
0
    def test_uncompress_is_working_properly_7(self):
        """testing if uncompress is working properly
        """
        seq7 = uncompress(
            'a.%03d.tga 1-100000 ([1-10, 100000])',
            fmt='%h%p%t %r (%R)'
        )
        self.assertEqual(
            'a.1-100000.tga',
            str(seq7)
        )

        self.assertEqual(
            11,
            len(seq7)
        )
示例#18
0
    def test_uncompress_is_working_properly_7(self):
        """testing if uncompress is working properly,
        the frame 100000 does not fit inside the pad length
        """
        seq7 = uncompress(
            'a.%03d.tga 1-100000 ([1-10, 100000])',
            fmt='%h%p%t %r (%R)'
        )
        self.assertEqual(
            'a.1-10.tga',
            str(seq7)
        )

        self.assertEqual(
            10,
            len(seq7)
        )
示例#19
0
    def process(self, context, instance):

        ftrack_data = context.data('ftrackData')

        root = ftrack_data['Project']['root']

        task = ftrack.Task(ftrack_data['Task']['id'])
        parent_name = task.getParent().getName()

        task_name = ftrack_data['Task']['name'].replace(' ', '_').lower()
        version_name = 'v' + str(context.data('version')).zfill(3)

        # making directories
        path = os.path.join(root, 'renders', 'img_sequences', parent_name,
                                        task_name, version_name, str(instance))
        if not os.path.exists(path):
            os.makedirs(path)

        # copy files
        component_path = None
        try:
            seq = pyseq.uncompress(instance.data('path'), fmt='%h%p%t %R')
            root = os.path.dirname(seq.path())
            component_path = os.path.join(path, seq.format('%h%p%t %R'))

            for f in seq:
                src = os.path.join(root, f)
                dst = os.path.join(path, f)

                shutil.copy(src, dst)
        except:
            root = os.path.dirname(instance.data('path'))
            f = os.path.basename(instance.data('path'))
            src = os.path.join(root, f)
            dst = os.path.join(path, f)
            component_path = dst

            shutil.copy(src, dst)

        components = instance.data('ftrackComponents')
        components[str(instance)]['path'] = component_path
        instance.set_data('ftrackComponents', value=components)
示例#20
0
    def process(self, context, instance):

        ftrack_data = context.data('ftrackData')

        root = ftrack_data['Project']['root']

        task = ftrack.Task(ftrack_data['Task']['id'])
        parent_name = task.getParent().getName()

        task_name = ftrack_data['Task']['name'].replace(' ', '_').lower()
        version_name = 'v' + str(context.data('version')).zfill(3)

        # making directories
        path = os.path.join(root, 'renders', 'img_sequences', parent_name,
                            task_name, version_name, str(instance))
        if not os.path.exists(path):
            os.makedirs(path)

        # copy files
        component_path = None
        try:
            seq = pyseq.uncompress(instance.data('path'), fmt='%h%p%t %R')
            root = os.path.dirname(seq.path())
            component_path = os.path.join(path, seq.format('%h%p%t %R'))

            for f in seq:
                src = os.path.join(root, f)
                dst = os.path.join(path, f)

                shutil.copy(src, dst)
        except:
            root = os.path.dirname(instance.data('path'))
            f = os.path.basename(instance.data('path'))
            src = os.path.join(root, f)
            dst = os.path.join(path, f)
            component_path = dst

            shutil.copy(src, dst)

        components = instance.data('ftrackComponents')
        components[str(instance)]['path'] = component_path
        instance.set_data('ftrackComponents', value=components)
示例#21
0
    def evaluate_script(self, checker=0):
        """
            :param checker: 1 = Regular evaluation, mostly useful from panel itself
                            2 = Return dictionary of parsed 'Read' nodes
            :return: {'/path/to/sequence_%0Xd.xxx': [first_frame, last_frame, size_in_bytes]}
            """
        files_to_check = {}
        readTypes = ('Read', 'DeepRead', 'ReadGeo2')

        def fill_files(N):
            """
                :param N: read node within group/gizmo or directly from DAG
                :return: updated files_to_check or None
                """
            if N.knob('disable').value():
                if not self.disabledBool.value():
                    return None
            file_path = N.knob('file').value()
            if file_path:
                if N.Class() == "ReadGeo2":
                    first = int(N.knob('range_first').value())
                    last = int(N.knob('range_last').value())
                else:
                    first = int(N.knob('first').value())
                    last = int(N.knob('last').value())
                if "%d" in file_path:
                    numbering = "%0" + str(len(str(last))) + "d"
                    file_path = file_path.replace("%d", numbering)
                return files_to_check.update({file_path: [first, last]})

        for node in nuke.allNodes():
            if node.knob('gizmo_file') or node.Class() == "Group":
                for subNode in nuke.toNode(node.name()).nodes():
                    if subNode.Class() in readTypes:
                        if DEV > 1:
                            print "Adding: " + subNode.fullName(
                            ) + ", class: " + str(subNode.Class())
                            print subNode.knob('file').value() + "\n"
                        fill_files(N=subNode)
            else:
                if node.Class() in readTypes:
                    if DEV > 1:
                        print "Adding: " + node.fullName() + ", class: " + str(
                            node.Class())
                        print node.knob('file').value() + "\n"
                    fill_files(N=node)

        if checker == 1:
            print "\n~ There are " + str(
                len(files_to_check)) + " sequences in this script.\n"

        total_size = 0
        seq_errors = 0
        seq_suspicious = 0
        nice_files_to_check = {}
        for sequence, metadata in files_to_check.iteritems():
            if DEV > 0:
                print "\n* Sequence: " + sequence
                print "range: " + str(metadata)
            seq_padding = "".join(sequence.split("/")[-1].split(".")[:-1])
            if "%d" in seq_padding:
                seq_numbering = "%0" + str(len(str(metadata[1]))) + "d"
                sequence = sequence.replace("%d", seq_numbering)
                if DEV > 0:
                    print "New sequence name: " + sequence
            elif "#" in seq_padding:
                seq_numbering = "%0" + str(seq_padding.count("#")) + "d"
            elif "%" in seq_padding:
                seq_numbering = "%" + seq_padding.split("%")[-1]
            else:
                seq_numbering = None
            seq_name_full = sequence + " " + str(metadata[0]) + "-" + str(
                metadata[1])
            seq_object = pyseq.uncompress(seq_name_full, format="%h%p%t %r")
            seq_folder = "/".join(sequence.split("/")[:-1])
            seq_niceName = sequence.split("/")[-1]
            seq_size = 0
            if DEV > 0:
                print "seq_numbering: " + str(seq_numbering)
                print "seq_name_full: " + seq_name_full
                print "seq_object: " + str(seq_object)
                print "seq_folder: " + seq_folder
                print "seq_niceName: " + seq_niceName

            def splitter(a, n):
                """
                        :param a: divide A
                        :param n: by N parts
                        :return: equally splitted lists
                        """
                k, m = len(a) / n, len(a) % n
                return (a[i * k + min(i, m):(i + 1) * k + min(i + 1, m)]
                        for i in xrange(n))

            if seq_object:
                if metadata[1] - metadata[0] > self.prj_length + 50:
                    seq_suspicious += 1
                seq_length = int(len(seq_object.frames())) - 1
                if DEV > 0:
                    print "seq_length: %s" % seq_length
                if seq_length <= self.precisionValue.value():
                    if seq_length < 2:
                        seq_frame = seq_object.format(
                            '%h') + seq_object.format('%t')
                        seq_frame_path = os.path.join(seq_folder, seq_frame)
                        if DEV > 0:
                            print ".: " + seq_frame_path
                        if os.path.isfile(seq_frame_path) is True:
                            seq_size += abs(os.path.getsize(seq_frame_path))
                        else:
                            if DEV > 0:
                                print "\n! something wrong with " + seq_frame_path + "\n"
                    else:
                        for frame in seq_object.frames():
                            if seq_numbering:
                                frame = str(frame).zfill(int(seq_numbering[2]))
                                seq_frame = seq_object.format(
                                    '%h') + frame + seq_object.format('%t')
                                seq_frame_path = os.path.join(
                                    seq_folder, seq_frame)
                            if DEV > 0:
                                print ".: " + seq_frame_path
                            if os.path.isfile(seq_frame_path) is True:
                                seq_size += abs(
                                    os.path.getsize(seq_frame_path))
                            else:
                                if DEV > 0:
                                    print "\n! something wrong with " + seq_frame_path + "\n"
                else:
                    approx_size = 0
                    calculated = 0
                    split = list(
                        splitter(seq_object.frames(),
                                 self.precisionValue.value()))
                    for x in split:
                        frame = str(x[0]).zfill(int(seq_numbering[2]))
                        seq_frame = seq_object.format(
                            '%h') + frame + seq_object.format('%t')
                        seq_frame_path = os.path.join(seq_folder, seq_frame)
                        if os.path.isfile(seq_frame_path) is True:
                            approx_size += abs(os.path.getsize(seq_frame_path))
                            calculated += 1
                        else:
                            if DEV > 0:
                                print "\n! something wrong with " + seq_frame_path + "\n"
                    if calculated > 1:
                        f_approx_size = approx_size / calculated
                        e_approx_size = f_approx_size * seq_length
                        seq_size += e_approx_size
                        if DEV > 0:
                            print str(e_approx_size) + " = " + str(
                                f_approx_size) + " * " + str(seq_length)
                    else:
                        seq_size += e_approx_size
            else:
                if DEV > 0:
                    print "estimating SINGLE file: " + sequence
                if os.path.isfile(sequence) is True:
                    seq_size += abs(os.path.getsize(sequence))

            files_to_check[sequence].append(seq_size)

            if checker == 1:
                constr = None
                if seq_size > 0:
                    if self.pathBool.value() is False:
                        constr = seq_niceName
                    else:
                        constr = sequence
                else:
                    seq_errors += 1
                if not self.sortedBool.value():
                    if constr:
                        print "* " + constr + " .... " + sconvert(seq_size)
                else:
                    if constr:
                        nice_files_to_check[constr] = files_to_check[sequence]
                total_size += seq_size

        if self.sortedBool.value():
            for x in nice_files_to_check:
                nice_files_to_check[x] = nice_files_to_check[x][2]
            sorted_files_to_check = sorted(nice_files_to_check.items(),
                                           key=operator.itemgetter(1),
                                           reverse=True)
            for x in sorted_files_to_check:
                print "* " + str(x[0]) + " .... " + sconvert(int(x[1]))

        if checker == 1:
            print "\n~ Total size: " + sconvert(total_size)
            if seq_suspicious > 0:
                print "~ Suspiciously big sequences: %s" % seq_suspicious
            elif seq_errors > 0:
                print "! Unreadable read nodes: %s" % seq_errors

        if checker == 2:
            return files_to_check