Beispiel #1
0
def create_gif_thumb(sequence,
                     ext='gif',
                     width='100',
                     height='x100',
                     do_height=True,
                     verbose=True):
    if do_height:
        res = height
    else:
        res = width
    path_object = PathObject(sequence)
    new_res = 'gif'
    path_object_output = path_object.copy(resolution=new_res)
    output_dir = os.path.dirname(path_object_output.path_root)
    out_seq = ''
    command = ''
    if not os.path.exists(output_dir):
        CreateProductionData(path_object=output_dir, project_management=False)
    if '####' in sequence:
        in_seq = '%s*.%s' % (split_sequence(sequence), path_object.ext)
        out_seq = '%s/%sthumb.%s' % (
            output_dir, os.path.basename(split_sequence(sequence)), ext)
        command = '%s %s -resize %s %s' % (CONFIG['magick'], in_seq, res,
                                           out_seq)

    if command:
        cgl_execute(command, verbose=verbose)
        return out_seq
Beispiel #2
0
def create_proxy(sequence, ext='jpg', verbose=True, methodology='local'):
    """
    Creates a Jpeg proxy resolution based off the resolution of the given path.
    :param sequence:
    :param ext:
    :param project_management:
    :return:
    """
    out_seq = ''
    path_object = PathObject(sequence)
    start_frame = get_start_frame(sequence)
    new_res = '%s%s' % (path_object.resolution, 'Proxy')
    path_object_output = path_object.copy(resolution=new_res, ext='jpg')
    output_dir = os.path.dirname(path_object_output.path_root)
    if not os.path.exists(output_dir):
        CreateProductionData(path_object=output_dir, project_management=False)
    if '####' in sequence:
        # replace ### with "*"
        number = hash_to_number(sequence)[-1]
        in_seq = '%s*.%s' % (split_sequence(sequence), path_object.ext)
        out_seq = '%s/%s%s.%s' % (output_dir,
                                  os.path.basename(
                                      split_sequence(sequence)), number, ext)
        command = '%s %s -scene %s %s' % (CONFIG['magick'], in_seq,
                                          start_frame, out_seq)
        run_dict = cgl_execute(command,
                               methodology=methodology,
                               verbose=verbose)
        run_dict['file_out'] = out_seq
        write_to_cgl_data(run_dict)
    return run_dict
    def run(self):
        d = datetime.datetime.today()
        current_date = d.strftime('%d-%m-%Y %H:%M:%S')
        for index, row in self.data_frame.iterrows():
            if row['Status'] == 'Tagged':
                from_file = row['Filepath']
                to_file = row['Publish_Filepath']
                if row['Filetype'] == 'folder':
                    print 'Copying %s to %s' % (from_file, to_file)
                    # Send this to the Preflights - No matter what basically
                    if not self.test:
                        cgl_copy(from_file, to_file)
                        CreateProductionData(to_file, json=True)
                    self.shared_data['file_tree'].model.item(index, STATUS).setText('Published')
                    self.signal_one.emit([index, STATUS, 'Published'])
                    self.data_frame.at[index, 'Status'] = 'Published'
                    self.data_frame.at[index, 'Publish_Date'] = current_date
                    row['Publish_Date'] = current_date
                    row['Status'] = 'Published'
                    self.make_source_file(to_file, row)

                elif row['Filetype'] == 'sequence':
                    to_dir = os.path.dirname(to_file)
                    if not self.test:
                        CreateProductionData(to_dir)
                    file_sequence, self.shared_data['frange'] = split_sequence_frange(from_file)
                    from_query = split_sequence(from_file)
                    from_filename = os.path.split(file_sequence)[-1]
                    self.shared_data['published_seq'] = os.path.join(to_dir, from_filename)

                    for f in glob.glob('%s*' % from_query):
                        to_file = os.path.join(to_dir, os.path.basename(f))
                        print 'Copying %s to %s' % (f, to_file)
                        if not self.test:
                            cgl_copy(f, to_file)
                        self.shared_data['file_tree'].model.item(index, STATUS).setText('Published')
                        self.data_frame.at[index, 'Status'] = 'Published'
                        self.data_frame.at[index, 'Publish_Date'] = current_date
                        row['Publish_Date'] = current_date
                        row['Status'] = 'Published'
                        self.make_source_file(to_dir, row)
                else:
                    print 'FILETYPE =', row['Filetype']

                    if not self.test:
                        print 'Copying %s to %s' % (from_file, to_file)
                        CreateProductionData(os.path.dirname(to_file))
                        cgl_copy(from_file, to_file)
                        self.shared_data['publish_file'] = to_file
                    self.shared_data['file_tree'].model.item(index, STATUS).setText('Published')
                    self.data_frame.at[index, 'Status'] = 'Published'
                    self.data_frame.at[index, 'Publish_Date'] = current_date
                    row['Publish_Date'] = current_date
                    row['Status'] = 'Published'
                    self.make_source_file(to_file, row)
                self.pass_check('Check Passed')
                print self.shared_data['publish_file']
                if not self.test:
                    self.save_data_frame()
    def run(self):
        d = datetime.datetime.today()
        current_date = d.strftime('%d-%m-%Y %H:%M:%S')
        # This is publishing EVERYTHING, what about the scenario when we don't want that?
        # can i get the selected row only?
        for index, row in self.data_frame.iterrows():
            if row['Filename'] == self.current_selection[0][0]:
                if row['Status'] == 'Tagged':
                    from_file = row['Filepath']
                    to_file = row['Publish_Filepath']

                    # What to do if it's a Folder
                    if row['Filetype'] == 'folder':
                        print 'Copying %s to %s' % (from_file, to_file)
                        # Send this to the Preflights - No matter what basically
                        if not self.test:
                            cgl_copy(from_file, to_file)
                            CreateProductionData(to_file, json=True)
                        self.shared_data['file_tree'].model.item(
                            index, STATUS).setText('Published')
                        # noinspection PyUnresolvedReferences
                        # self.data_frame.at[index, 'Status'] = 'Published'
                        # self.data_frame.at[index, 'Publish_Date'] = current_date
                        row['Publish_Date'] = current_date
                        row['Status'] = 'Published'
                        self.make_source_file(to_file, row)

                    # What to do with Sequences:
                    else:
                        to_dir = os.path.dirname(to_file)
                        if row['Filetype'] == 'sequence':
                            print '2, Sequence'
                            if not self.test:
                                print 'Creating Directory: %s' % to_dir
                                CreateProductionData(to_dir)
                            file_sequence, self.shared_data[
                                'frange'] = split_sequence_frange(from_file)
                            from_query = split_sequence(from_file)
                            from_filename = os.path.split(file_sequence)[-1]
                            self.shared_data['published_seq'] = os.path.join(
                                to_dir, from_filename)

                            for f in glob.glob('%s*' % from_query):
                                to_file = os.path.join(to_dir,
                                                       os.path.basename(f))
                                print 'Copying %s to %s' % (f, to_file)
                                if not self.test:
                                    cgl_copy(f, to_file)
                                # self.shared_data['file_tree'].model.item(index, STATUS).setText('Published')
                                self.data_frame.at[index,
                                                   'Status'] = 'Published'
                                self.data_frame.at[
                                    index, 'Publish_Date'] = current_date
                                row['Publish_Date'] = current_date
                                row['Status'] = 'Published'
                                self.make_source_file(to_dir, row)
                        else:
                            print '4 File'
                            print 'Copying %s to %s' % (from_file, to_file)
                            if not self.test:
                                print 'Creating File: %s' % to_file
                                CreateProductionData(to_file, json=True)
                                cgl_copy(from_file, to_file)
                            # self.shared_data['file_tree'].model.item(index, STATUS).setText('Published')
                            self.data_frame.at[index, 'Status'] = 'Published'
                            self.data_frame.at[index,
                                               'Publish_Date'] = current_date
                            row['Publish_Date'] = current_date
                            row['Status'] = 'Published'
                            self.make_source_file(to_file, row)
                    self.save_data_frame()
                    self.pass_check('Check Passed')
                else:
                    print 'Skipping Untagged assets'
Beispiel #5
0
def create_hd_proxy(sequence,
                    output=None,
                    mov=None,
                    ext='jpg',
                    width='1920',
                    height='x1080',
                    do_height=False,
                    start_frame=None,
                    verbose=True,
                    methodology='local',
                    dependent_job=None):
    """
    Create HD Proxy Sequence from a givein image sequence.
    :param sequence:
    :param output:
    :param mov:
    :param ext:
    :param width:
    :param height:
    :param do_height:
    :param start_frame:
    :param verbose:
    :param methodology:
    :param dependent_job:
    :return:
    """

    if do_height:
        res = height
    else:
        res = width
    path_object = PathObject(sequence)
    path_object.set_file_type()
    hashes = ''
    fileout = ''
    out_seq = ''
    command = ''
    number = ''
    if not output:
        logging.info('No output defined for create_hd_proxy')
    else:
        path_object_output = None
        output_dir = os.path.dirname(output)
    if path_object.file_type == 'sequence':
        # replace ### with "*"
        if '##' in sequence:
            hashes, number = hash_to_number(sequence)
        elif '%0' in sequence:
            hashes, number = number_to_hash(sequence)
        in_seq = '%s*.%s' % (split_sequence(sequence), path_object.ext)
        out_seq = '%s/%s%s.%s' % (output_dir,
                                  os.path.basename(
                                      split_sequence(sequence)), number, ext)
        fileout = out_seq.replace(number, hashes)
    elif path_object.file_type == 'image':
        sequence = sequence
        try:
            path_object_output.set_attr(ext='jpg')
            fileout = path_object_output.path_root
        except AttributeError:
            this_ = os.path.splitext(output)[0]
            fileout = this_ + '.jpg'
        command = '%s %s -resize %s %s' % (CONFIG['magick'], sequence, res,
                                           fileout)

    if methodology == 'smedge':
        print "I'm sending this to smedge to start after %s" % dependent_job
        command = r'python %s -i %s' % (__file__, sequence)
        # set_process_time = r'"python %s -e True -j %s -k farm_processing_end"' % (util_file, '%SMEDGE_JOB_ID%')
        # run_dict = cgl_execute(command, command_name='create_hd_proxy', methodology=methodology,
        #                        Wait=dependent_job, WorkPostExecuteSuccessfulEvt=set_process_time)
        run_dict = cgl_execute(command,
                               command_name='%s_%s: create_hd_proxy' %
                               (path_object.seq, path_object.shot),
                               methodology='smedge',
                               Wait=dependent_job)
        run_dict['file_out'] = fileout
        write_to_cgl_data(run_dict)
        return run_dict

    if not start_frame:
        start_frame = get_start_frame(sequence)

    if path_object.file_type == 'sequence':
        command = '%s %s -scene %s -resize %s %s' % (CONFIG['magick'], in_seq,
                                                     start_frame, res, out_seq)
    if not os.path.exists(output_dir):
        CreateProductionData(path_object=output_dir,
                             project_management='lumbermill')
    run_dict = cgl_execute(command,
                           verbose=verbose,
                           methodology=methodology,
                           command_name='%s_%s: create_hd_proxy' %
                           (path_object.seq, path_object.shot),
                           Wait=dependent_job)
    run_dict['file_out'] = fileout
    write_to_cgl_data(run_dict)
    print 'file_out: %s' % fileout
    return run_dict