Пример #1
0
def run():
    """
    This run statement is what's executed when your button is pressed in blender.
    :return:
    """

    scene = alc.scene_object()

    if scene.context == 'source':
        if scene.resolution == 'high':
            alc.version_up()


            bpy.ops.file.make_paths_relative()

            low_res = alc.scene_object().copy(resolution='low')
            for res in low_res.glob_project_element('filename'):
                create_file_dirs(res)
                cgl_copy(res.path_root, low_res.path_root)

            alc.confirm_prompt(message="Version up to {}".format(alc.scene_object().version))

        else:
            alc.confirm_prompt(message="This is a low resolution version , please edit source file")

    else:
        alc.confirm_prompt(message="files in the render context shouldn't be versioned up, please edit source file")
Пример #2
0
 def file_interaction(self, files, path, to_folder):
     # TODO - ultimately we want to figure out how to handle the progress bar through the cgl_execute function.
     if path == '*':
         print 'Please Select An Ingest Source Before Dragging Files'
         return
     from cgl.core.utils.general import cgl_copy
     publish_data_csv = os.path.join(to_folder,
                                     'publish_data.csv').replace('\\', '/')
     if os.path.exists(to_folder):
         create_new = False
     else:
         create_new = True
     cgl_copy(files, to_folder, verbose=False, dest_is_folder=True)
     self.progress_bar.hide()
     if create_new:
         self.load_import_events(new=True)
         num = self.ingest_widget.list.count()
         item = self.ingest_widget.list.item(num - 1)
         item.setSelected(True)
         self.parent().parent().centralWidget().update_location_to_latest(
             self.path_object)
         # self.empty_state.hide()
     if os.path.exists(publish_data_csv):
         os.remove(publish_data_csv)
         time.sleep(
             .5
         )  # seems like on the network i have to force it to sleep so it has time to delete.
     self.load_data_frame()
     self.populate_tree()
Пример #3
0
 def copy_cgl_tools(self):
     from cgl.core.utils.general import cgl_copy
     src = os.path.join(self.widget_dict['code_root']['line_edit'].text(),
                        'cgl', 'cfg', 'cgl_tools')
     dst = os.path.join(self.widget_dict['cgl_tools']['line_edit'].text())
     if not os.path.exists(dst):
         cgl_copy(src, dst)
Пример #4
0
def move_to_project(project):
    context = ['source', 'render']
    scene = alc.scene_object()
    for item in context:
        fromDir = scene.copy(context=item, filename=None).path_root
        toDir = scene.copy(context=item, filename=None,
                           project=project).path_root
        cgl_copy(fromDir, toDir)
Пример #5
0
 def on_copy_clicked(self):
     from_path = self.copy_from_path.text()
     to_path = self.copy_to_path.text()
     other_from_path = self.other_path_object.path_root
     other_to_path = self.other_to_object.path_root
     print('Copying %s to %s' % (from_path, to_path))
     print('Copying %s to %s' % (other_from_path, other_to_path))
     cgl_copy(from_path, to_path)
     cgl_copy(other_from_path, other_to_path)
     self.accept()
Пример #6
0
 def ingest_folder(self, index, row, from_file, to_file, current_date):
     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, methodology=METHODOLOGY)
         CreateProductionData(to_file, json=True)
     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)
Пример #7
0
 def version_up_selected_clicked(self):
     current = PathObject(self.current_location)
     # current location needs to have the version in it.
     next_minor = current.new_minor_version_object()
     next_minor.set_attr(filename='')
     next_minor.set_attr(resolution=self.current_location['resolution'])
     next_minor.set_attr(ext='')
     CreateProductionData(next_minor)
     cgl_copy(os.path.dirname(current.path_root), next_minor.path_root)
     # reselect the original asset.
     self.on_task_selected(next_minor)
Пример #8
0
 def ingest_file(self, index, row, from_file, to_file, current_date):
     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, methodology=METHODOLOGY)
         self.shared_data['publish_path_object'] = PathObject(to_file)
     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)
Пример #9
0
    def new_files_dragged(self, files):
        to_object = PathObject(self.sender().to_object)
        to_folder = to_object.path_root

        for f in files:
            file_ = os.path.split(f)[-1]
            to_file = os.path.join(to_folder, file_)
            if '.' in file_:
                logging.info('Copying %s to %s' % (f, to_file))
                cgl_copy(f, to_file)
                CreateProductionData(path_object=to_object)
                self.on_task_selected(self.version_obj)
            else:
                logging.info('Copying directory %s to %s' % (f, to_file))
                cgl_copy(f, to_file)
                CreateProductionData(path_object=to_object)
                self.on_task_selected(self.version_obj)
 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)
Пример #11
0
def create_project_config(company, project):
    """
    Creates the config for a project
    :param company:
    :param project:
    :return:
    """
    from cgl.core.utils.general import cgl_copy
    config_dir = os.path.dirname(UserConfig().user_config_path)
    company_config = os.path.join(config_dir, 'companies', company,
                                  'global.yaml')
    project_dir = os.path.join(config_dir, 'companies', company, project)
    project_config = os.path.join(project_dir, 'global.yaml')
    if os.path.exists(company_config):
        if not os.path.exists(project_dir):
            print project_dir
            os.makedirs(project_dir)
            cgl_copy(company_config, project_config)
Пример #12
0
def copy_latest_low():
    versions = get_items()
    scene = alc.scene_object()
    low_found = None
    for i in versions:
        if not low_found:

            low = scene.copy(version=i, resolution='low')
            low_dir = low.copy(filename='')

            if os.path.isdir(low_dir.path_root):
                print(low.path_root)
                low_found = low_dir

    cgl_copy(low_found.path_root,
             scene.copy(resolution='low', filename='').path_root)
    cgl_copy(
        low_found.path_root,
        scene.copy(context='render', resolution='low', filename='').path_root)
Пример #13
0
 def on_icon_button_clicked(self):
     default_folder = os.path.join(get_cgl_tools(), self.software, self.menu_type, self.preflight_name)
     file_paths = QtWidgets.QFileDialog.getOpenFileName(self, 'Choose a File to Attach', default_folder, "*")
     from_path = file_paths[0].replace('\\', '/')
     _, file_ = os.path.split(from_path)
     to_path = os.path.join(default_folder, file_).replace('\\', '/')
     if from_path != to_path:
         dirname = os.path.dirname(to_path)
         if not os.path.exists(dirname):
             os.makedirs(dirname)
         cgl_copy(from_path, to_path)
     self.icon_path_line_edit.setText(to_path)
     icon = QtGui.QIcon(to_path)
     tab_ = self.parent().parent()
     index_ = tab_.currentIndex()
     # print index_
     tab_.setTabIcon(index_, icon)
     # # display the icon?
     self.on_save_clicked()
Пример #14
0
 def on_file_dragged(self, path_object, data):
     logging.debug('Path: %s has files added to it' % path_object.path_root)
     self.update_task_location(path_object)
     self.clear_task_selection_except(path_object.task)
     to_path = path_object.path_root
     if os.path.isfile(to_path):
         to_path = os.path.dirname(to_path)
     elif to_path.endswith('*'):
         to_path = os.path.dirname(to_path)
     for d in data:
         filename_ = os.path.split(d)[-1]
         if os.path.isfile(d):
             filename_ = replace_illegal_filename_characters(filename_)
             logging.info('Copying File From %s to %s' %
                          (d, os.path.join(to_path, filename_)))
             cgl_copy(d, os.path.join(to_path, filename_))
         elif os.path.isdir(d):
             logging.info('Copying Folder From %s to %s' % (d, to_path))
             cgl_copy(d, os.path.join(to_path, filename_))
     self.parent().progress_bar.hide()
    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()
Пример #16
0
 def ingest_sequence(self, index, row, from_file, to_file, current_date):
     to_dir = os.path.dirname(to_file)
     if not self.test:
         CreateProductionData(to_dir)
     from_filename = os.path.split(from_file)[-1]
     self.shared_data['publish_path_object'] = PathObject(
         os.path.join(to_dir, from_filename))
     print 'Copying sequence %s to %s' % (from_file, to_dir)
     seq = self.shared_data['publish_path_object'].seq
     shot = self.shared_data['publish_path_object'].shot
     info_ = cgl_copy(from_file,
                      to_dir,
                      methodology=METHODOLOGY,
                      job_name='%s_%s' % (seq, shot))
     self.shared_data['copy_job_id'] = info_['job_id']
     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)
def copy_latest_high():
    scene = alc.scene_object()
    latest_high_folder = get_latest_high().copy(filename=None, ext=None).path_root
    current_high_folder = scene.copy(filename=None, ext=None, resolution='high').path_root
    cgl_copy(latest_high_folder, current_high_folder)
Пример #18
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
Пример #19
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
Пример #20
0
def copy_to_next_version():
    print 'copying %s to %s' % (DEVROOT, next_release_folder())
    cgl_copy(DEVROOT, next_release_folder())
Пример #21
0
    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'
Пример #22
0
def copy_to_latest():
    # TODO this really needs to be robocopy, so slow!!!
    print 'copying %s to %s' % (DEVROOT, LATEST)
    cgl_copy(DEVROOT, LATEST, dest_is_folder=True)