Exemple #1
0
 def on_root_edited(self):
     self.root = os.path.join(self.drive, self.root_line_edit.text()).replace('\\', '/')
     self.to_object = PathObject.copy(self.path_object, root=self.root)
     if self.to_object.context == 'source':
         self.other_to_object = PathObject.copy(self.to_object, context='render')
     else:
         self.other_to_object = PathObject.copy(self.to_object, context='source')
     self.copy_to_path.setText(self.to_object.path_root.replace('\\', '/'))
Exemple #2
0
 def on_drive_changed(self):
     self.drive = self.drive_combo.currentText()
     self.root = os.path.join(self.drive, 'CGL_EXPORT', 'COMPANIES')
     self.root_line_edit.setText(self.root)
     self.to_object = PathObject.copy(self.path_object, root=self.root)
     if self.to_object.context == 'source':
         self.other_to_object = PathObject.copy(self.to_object, context='render')
     else:
         self.other_to_object = PathObject.copy(self.to_object, context='source')
     self.copy_to_path.setText(self.to_object.path_root.replace('\\', '/'))
Exemple #3
0
    def __init__(self, path_object):
        LJDialog.__init__(self)
        self.path_object = path_object
        if self.path_object.context == 'source':
            self.other_path_object = PathObject.copy(path_object, context='render')
        else:
            self.other_path_object = PathObject.copy(path_object, context='source')
        # TODO - i need something here to check if i'm in a task or not, if not send a popup
        task = path_object.task
        seq = path_object.seq
        shot = path_object.shot
        self.to_object = None
        self.root = ''
        all_ = r'%s/%s/%s' % (seq, shot, task)
        self.setWindowTitle('Export %s to drive' % all_)
        v_layout = QtWidgets.QVBoxLayout(self)
        grid_layout = QtWidgets.QGridLayout()
        button_layout = QtWidgets.QHBoxLayout()
        drive_label = QtWidgets.QLabel('External Drive:')
        self.drive_combo = AdvComboBox()
        root_label = QtWidgets.QLabel('External Drive Root:')
        self.root_line_edit = QtWidgets.QLineEdit()
        copy_from_label = QtWidgets.QLabel('copy from:')
        self.copy_from_path = QtWidgets.QLabel(path_object.path_root)
        copy_to_label = QtWidgets.QLabel('copy to')
        self.copy_to_path = QtWidgets.QLabel('')
        self.message = QtWidgets.QLabel('')
        self.cancel_button = QtWidgets.QPushButton('Cancel')
        self.ok_button = QtWidgets.QPushButton('Copy Task')

        grid_layout.addWidget(drive_label, 0, 0)
        grid_layout.addWidget(self.drive_combo, 0, 1)
        grid_layout.addWidget(root_label, 1, 0)
        grid_layout.addWidget(self.root_line_edit, 1, 1)
        grid_layout.addWidget(copy_from_label, 2, 0)
        grid_layout.addWidget(self.copy_from_path, 2, 1)
        grid_layout.addWidget(copy_to_label, 3, 0)
        grid_layout.addWidget(self.copy_to_path, 3, 1)

        button_layout.addStretch(1)
        button_layout.addWidget(self.cancel_button)
        button_layout.addWidget(self.ok_button)

        v_layout.addLayout(grid_layout)
        v_layout.addWidget(self.message)
        v_layout.addLayout(button_layout)

        self.drive_combo.currentIndexChanged.connect(self.on_drive_changed)
        self.root_line_edit.textChanged.connect(self.on_root_edited)
        self.cancel_button.clicked.connect(self.on_cancel_clicked)
        self.ok_button.clicked.connect(self.on_copy_clicked)
        self.get_available_drives()
 def on_file_dragged_to_source(self, data):
     object_ = PathObject.copy(self.version_obj, context='source')
     process_method(self.parent().progress_bar,
                    self.on_file_dragged,
                    args=(object_, data),
                    text='Lumber-hacking Files')
     self.on_task_selected(object_)
Exemple #5
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
Exemple #6
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):
     path_object = self.shared_data['path_object']
     user = path_object.user
     if path_object.context != 'render':
         path_object = PathObject.copy(path_object, context='render')
     from_dir = os.path.dirname(path_object.path_root)
     pub_obj = PathObject(from_dir)
     pub_obj = pub_obj.copy(latest=True)
     pub_obj.set_attr(user='******')
     pub_obj = pub_obj.next_major_version()
     major_version_obj = pub_obj.copy(user=user)
     for each in os.listdir(from_dir):
         print(os.path.join(from_dir, each), os.path.join(major_version_obj.path_root, each))
         print(os.path.join(from_dir, each), os.path.join(pub_obj.path_root, each))
         cgl_copy(os.path.join(from_dir, each), os.path.join(major_version_obj.path_root, each))
         cgl_copy(os.path.join(from_dir, each), os.path.join(pub_obj.path_root, each))
     self.pass_check('Done Copying Render Files to %s' % pub_obj.path_root)
 def update_task_location(self, path_object):
     """
     Method that sends the path object dictionary for anything happening within the Tasks Panel.
     :param path_object:
     :return:
     """
     if path_object:
         if isinstance(path_object, dict):
             path_object = PathObject(path_object)
         self.current_location = path_object.data
         self.path_object = path_object.copy()
         self.location_changed.emit(self.path_object)
    def run(self):
        """
        Checking to see if there are files within the "render" folder area.  I should expect that i'm going to get a
        filename, but i will check for it anyway.
        :return:
        """
        path_object = self.shared_data['path_object']
        if path_object.filename:
            if path_object.context != 'render':
                path_object = PathObject.copy(path_object, context='render')
            render_dir = os.path.dirname(path_object.path_root)
            if os.path.exists(render_dir):
                if os.listdir(render_dir):
                    self.pass_check('Found Render Files')
                    return
        else:
            print 'File Name Not Defined'

        self.fail_check('No Render Files Found at: %s \nCheck Failed' %
                        os.path.dirname(path_object.path_root))
Exemple #10
0
    def load_render_files(self, widget):

        logging.debug('loading render files')
        widget.files_area.work_files_table.show()
        render_table = widget.files_area.export_files_table
        current = PathObject(self.version_obj)
        if widget.files_area.work_files_table.user:
            renders = current.copy(
                context='render',
                task=widget.task,
                user=widget.files_area.work_files_table.user,
                version=widget.files_area.work_files_table.version,
                resolution=widget.files_area.work_files_table.resolution,
                filename='*')
            files_ = glob.glob(renders.path_root)
            if current.user == 'publish':
                render_files_label = 'Published Files'
                widget.files_area.publish_button.hide()
                widget.files_area.new_version_button.hide()
            else:
                widget.files_area.new_version_button.show()
                widget.files_area.review_button.show()
                widget.files_area.publish_button.show()
                render_files_label = 'Ready to Review/Publish'
            logging.debug('Published Files for %s' % current.path_root)
            data_ = self.prep_list_for_table(files_, basename=True, length=1)
            model = FilesModel(data_, [render_files_label])
            widget.setup(render_table, model)
            render_table.show()
            widget.files_area.open_button.show()
            widget.empty_state.hide()
            if not files_:
                widget.files_area.review_button.hide()
                widget.files_area.publish_button.hide()
                if not self.work_files:
                    render_table.hide()
                    widget.files_area.open_button.hide()
                    widget.files_area.new_version_button.hide()
                    widget.files_area.work_files_table.hide()
                    widget.empty_state.show()
Exemple #11
0
    def on_task_selected(self, data):
        try:
            if isinstance(data, PathObject):
                current = data.copy()
            elif isinstance(data, dict):
                'its a dict, this sucks'
                current = PathObject(data)
        except IndexError:
            print 'Nothing Selected'
            return
        if data:
            self.clear_layout(self.panel)
            # reset the GUI
            if not current.task:
                current.set_attr(task='*')
            current.set_attr(root=self.path_object.root)
            # current.set_attr(user_email=self.user_email)
            self.panel.seq = current.seq
            self.panel.shot = current.shot
            self.update_task_location(path_object=current)
            self.panel.tasks = []
            try:
                if 'elem' in self.task:
                    title = self.task
                else:
                    title = self.proj_man_tasks_short_to_long[self.task]
            except KeyError:
                return
            task_widget = TaskWidget(parent=self,
                                     title=title,
                                     path_object=current,
                                     show_import=self.show_import)
            task_widget.task = self.task
            self.render_files_widget = task_widget.files_area.export_files_table
            task_widget.files_area.export_files_table.hide()
            self.task_widgets_dict[self.task] = task_widget

            # find the version information for the task:
            user = self.populate_users_combo(task_widget, current, self.task)
            self.current_location['user'] = user
            version = self.populate_versions_combo(task_widget, current,
                                                   self.task)
            self.current_location['version'] = version
            resolution = self.populate_resolutions_combo(
                task_widget, current, self.task)
            self.current_location['resolution'] = resolution
            self.update_task_location(self.current_location)
            self.panel.addWidget(task_widget)
            self.panel.tasks.append(self.task)
            self.version_obj = current.copy(task=self.task,
                                            user=user,
                                            version=version,
                                            resolution=resolution,
                                            context='source',
                                            filename='*')
            task_widget.files_area.work_files_table.task = self.version_obj.task
            task_widget.files_area.work_files_table.user = self.version_obj.user
            task_widget.files_area.work_files_table.version = self.version_obj.version
            task_widget.files_area.work_files_table.resolution = self.version_obj.resolution
            try:
                self.work_files = self.version_obj.glob_project_element(
                    'filename', full_path=True)
                self.high_files = self.version_obj.copy(
                    resolution='high').glob_project_element('filename',
                                                            full_path=True)
            except ValueError:
                self.work_files = []
                self.high_files = []
            # check to see if there are work files for the 'high' version
            self.render_files = []
            if user != 'publish':
                my_files_label = 'My Work Files'
                if not self.work_files:
                    my_files_label = 'Drag/Drop Work Files'
                    task_widget.files_area.work_files_table.hide()
            else:
                my_files_label = 'Published Work Files'
            logging.debug('Work Files: %s' % self.work_files)
            task_widget.setup(
                task_widget.files_area.work_files_table,
                FileTableModel(
                    self.prep_list_for_table(self.work_files, basename=True),
                    [my_files_label]))
            self.load_render_files(task_widget)
            task_widget.create_empty_version.connect(
                self.new_empty_version_clicked)
            task_widget.files_area.review_button_clicked.connect(
                self.on_review_clicked)
            task_widget.files_area.publish_button_clicked.connect(
                self.on_publish_clicked)
            task_widget.copy_latest_version.connect(
                self.new_version_from_latest)
            task_widget.copy_selected_version.connect(
                self.version_up_selected_clicked)
            task_widget.files_area.work_files_table.selected.connect(
                self.on_source_selected)
            task_widget.files_area.export_files_table.selected.connect(
                self.on_render_selected)
            task_widget.files_area.export_files_table.double_clicked.connect(
                self.on_render_double_clicked)
            task_widget.files_area.export_files_table.show_in_folder.connect(
                self.show_selected_in_folder)
            task_widget.files_area.work_files_table.doubleClicked.connect(
                self.on_open_clicked)
            task_widget.files_area.open_button.clicked.connect(
                self.on_open_clicked)
            task_widget.files_area.import_button.clicked.connect(
                self.on_import_clicked)
            task_widget.versions.currentIndexChanged.connect(
                self.on_task_info_changed)
            task_widget.users.currentIndexChanged.connect(
                self.on_task_info_changed)
            task_widget.resolutions.currentIndexChanged.connect(
                self.on_task_info_changed)
            task_widget.start_task_clicked.connect(
                self.on_assign_button_clicked)
            task_widget.files_area.work_files_table.dropped.connect(
                self.on_file_dragged_to_source)
            task_widget.files_area.export_files_table.dropped.connect(
                self.on_file_dragged_to_render)
            task_widget.files_area.work_files_table.show_in_folder.connect(
                self.show_selected_in_folder)
            task_widget.files_area.work_files_table.copy_folder_path.connect(
                self.copy_folder_path)
            task_widget.files_area.work_files_table.copy_file_path.connect(
                self.copy_file_path)
            task_widget.files_area.work_files_table.import_version_from.connect(
                self.import_versions_from)
            task_widget.empty_state.files_added.connect(
                self.on_file_dragged_to_source)
            if not user:
                task_widget.users_label.hide()
                task_widget.users.hide()
                task_widget.files_area.hide()
                task_widget.versions_label.hide()
                task_widget.versions.hide()
                task_widget.resolutions_label.hide()
                task_widget.resolutions.hide()
                task_widget.empty_state.hide()
                task_widget.status_button.hide()
            else:
                if task_widget.users.currentText() == current_user():
                    task_widget.refresh_task_info()
                else:
                    task_widget.status_button.hide()
Exemple #12
0
def do_review(progress_bar=None, path_object=None):
    import shutil
    import logging
    from cgl.core.utils.general import cgl_copy
    from cgl.ui.widgets.dialog import InputDialog
    job_id = None
    if not path_object:
        print 'No Valid PathObject() found for review'
        return None
    else:
        selection = path_object
        selection.set_preview_path()
        selection.set_hd_proxy_path()
        # selection.set_path()
    if os.path.isdir(selection.path_root):
        print 'Choose a sequence or file'
        return
    if not os.path.exists(selection.preview_path):
        print('No Web Preview Found, creating one')
        job_info = selection.make_preview()
        job_id = job_info['job_id']
    if selection.context == 'render':
        # lin_images = ['exr', 'dpx']
        # LUMBERMILL REVIEWS
        if PROJ_MANAGEMENT == 'lumbermill':
            # do this for movies
            print 'Lumbermill Not connected to review features'
        # FTRACK REVIEWS
        elif PROJ_MANAGEMENT == 'ftrack':
            if selection.filename:
                if selection.file_type == 'folder' or not selection.file_type:
                    dialog = InputDialog(
                        title='Error: unsupported folder or file_type',
                        message=
                        "%s is a folder or undefined file_type\nunsure how to proceed"
                        % selection.filename)
                    dialog.exec_()
                    if dialog.button == 'Ok' or dialog.button == 'Cancel':
                        dialog.accept()
                        return
                else:
                    selection.upload_review(job_id=job_id)
                    # CreateProductionData(selection)
            else:
                print('Select file for Review')

        elif PROJ_MANAGEMENT == 'shotgun':
            if selection.filename:
                if selection.file_type == 'folder' or not selection.file_type:
                    dialog = InputDialog(
                        title='Error: unsupported folder or file_type',
                        message=
                        "%s is a folder or undefined file_type\nunsure how to proceed"
                        % selection.filename)
                    dialog.exec_()
                    if dialog.button == 'Ok' or dialog.button == 'Cancel':
                        dialog.accept()
                        return
                else:
                    if os.path.exists(selection.preview_path):
                        print 1
                        CreateProductionData(path_object=selection)
                    else:
                        selection.upload_review(job_id=job_id)
            else:
                print('Select file for Review')

        else:
            print('%s is an unknown project management type' % PROJ_MANAGEMENT)

        selection.set_attr(filename='')
        selection.set_attr(ext='')
    else:
        dialog = InputDialog(title="Prep for Review",
                             message="Move or copy files to review area?",
                             buttons=['Move', 'Copy'])
        dialog.exec_()
        move = False
        if dialog.button == 'Move':
            move = True
        if selection.file_type == 'sequence':
            # sequence_name = selection.filename
            from_path = os.path.dirname(selection.path_root)
            to_object = PathObject(from_path)
            to_object.set_attr(context='render')
            for each in os.listdir(from_path):
                from_file = os.path.join(from_path, each)
                to_file = os.path.join(to_object.path_root, each)
                if move:
                    shutil.move(from_file, to_file)
                else:
                    cgl_copy(from_file, to_file)
            selection.set_attr(filename='')
            selection.set_attr(ext='')
        else:
            to_object = PathObject.copy(selection, context='render')
            logging.info('Copying %s to %s' %
                         (selection.path_root, to_object.path_root))
            if move:
                shutil.move(selection.path_root, to_object.path_root)
            else:
                cgl_copy(selection.path_root, to_object.path_root)
            selection.set_attr(filename='')
            selection.set_attr(ext='')
    if progress_bar:
        progress_bar.hide()
    return True
Exemple #13
0
def publish(path_obj):
    """
    Requires a path with render folder with existing data.
    Creates the next major version of the "USER" directory and copies all source & render files to it.
    Creates the Next Major Version of the "PUBLISH" directory and copies all source & render files to it.
    As a first step these will be the same as whatever is the highest directory.
    :param path_obj: this can be a path object, a string, or a dictionary
    :return: boolean depending on whether publish is successful or not.
    """
    # TODO this could be integrated with PathObject more elegantly
    import logging
    from cgl.core.utils.general import cgl_copy
    path_object = PathObject(path_obj)
    filename = path_object.filename
    resolution = path_object.resolution
    ext = path_object.ext
    # remove filename and ext to make sure we're dealing with a folder
    path_object = path_object.copy(filename='', ext='', resolution='')
    user = path_object.user
    if user != 'publish':
        if path_object.context == 'source':
            source_object = path_object
            render_object = PathObject.copy(path_object, context='render')
        else:
            source_object = PathObject.copy(path_object, context='source')
            render_object = path_object
        # Get the Right Version Number
        source_next = source_object.next_major_version()
        render_next = render_object.copy(version=source_next.version)
        source_pub = source_next.copy(user='******')
        render_pub = render_next.copy(user='******')

        for each in os.listdir(source_object.path_root):
            logging.info(
                'Copying Source Resolution %s from %s to %s' %
                (each, source_object.path_root, source_next.path_root))
            logging.info('Copying Source Resolution %s from %s to %s' %
                         (each, source_object.path_root, source_pub.path_root))
            cgl_copy(os.path.join(source_object.path_root, each),
                     os.path.join(source_next.path_root, each))
            cgl_copy(os.path.join(source_object.path_root, each),
                     os.path.join(source_pub.path_root, each))

        for each in os.listdir(render_object.path_root):
            logging.info(
                'Copying Render Resolution %s from %s to %s' %
                (each, render_object.path_root, render_next.path_root))
            logging.info('Copying Render Resolution %s from %s to %s' %
                         (each, render_object.path_root, render_pub.path_root))
            cgl_copy(os.path.join(render_object.path_root, each),
                     os.path.join(render_next.path_root, each))
            cgl_copy(os.path.join(render_object.path_root, each),
                     os.path.join(render_pub.path_root, each))
        # Register with Production Management etc...
        CreateProductionData(source_next)
        CreateProductionData(source_pub)

        return render_pub.copy(filename=filename,
                               resolution=resolution,
                               ext=ext)
    return False