Beispiel #1
0
def set_data(path, key, value):
    if os.path.exists(path):
        tmp_content = get_yml_file(path)
    else:
        tmp_content = {}
        libFunc.create_folder(path)
    tmp_content[key] = value
    set_yml_file(path, tmp_content)
Beispiel #2
0
def save_snapshot(rlt_path, src_path=default_tmp_path):
    img = QtGui.QImage()
    img.load(src_path)

    tmpDir = os.path.dirname(rlt_path) + '/' + libData.META_FOLDER
    rlt_path = tmpDir + "/" + os.path.basename(rlt_path).split(
        ".")[0] + libData.THUMBS_FORMAT

    libFunc.create_folder(rlt_path)
    img.save(rlt_path, format=libData.THUMBS_FORMAT)
    remove_tmp_img(src_path)
    return rlt_path
Beispiel #3
0
    def save_file_path(self):
        # USE ADDITIONAL PUBLISH SCRIPTS
        if self.wgHeader.cbxAdd.isChecked(): self.update_version()

        try:
            Tank().software.scene_saveAs(self.save_file)
            self.set_meta_data()
            LOG.info("SAVE : " + self.save_file)
        except:
            LOG.error("FAIL : Couldnt save file : {}".format(self.save_file), exc_info=True)
            return False

        if self.wgHeader.cbxAdd.isChecked():
            # COPY FILE WITH _PUBLISH
            tmpCopyWork = self.save_file.replace('.', '_{}.'.format(self.data['rules']['STATUS']['publish']))
            libSnapshot.save_snapshot(tmpCopyWork)
            self.set_meta_data(tmpCopyWork)

            found_version = re.search(self.data['rules']['FILE']['version'], os.path.basename(self.save_file))
            if found_version:
                old_version = re.search(r'\d+', found_version.group()).group()
                self.save_publish_file = self.save_file.split(found_version.group())[0] + '.' + Tank().software.extension

            if self.data['rules']['STATUS']['work'] in self.save_file:
                self.save_publish_file = self.save_publish_file.replace(self.data['rules']['STATUS']['work'], self.data['rules']['STATUS']['publish'])
            else:
                LOG.error("FAIL : NO {} in path : {}".format(self.data['rules']['STATUS']['work'], self.save_publish_file), exc_info=True)
                return False

            libFunc.create_folder(os.path.dirname(self.save_publish_file))

            try:
                shutil.copy(self.save_file, tmpCopyWork)
                shutil.copy(tmpCopyWork, self.save_publish_file)
            except:
                LOG.error("FAIL : Copying publish file : {}".format(self.save_publish_file), exc_info=True)
                return False

            LOG.info("PUBLISH : " + self.save_publish_file)
            libSnapshot.save_snapshot(self.save_publish_file)
            self.set_meta_data(self.save_publish_file)

        note = arNotice.Notice(title = os.path.basename(self.save_file).split('.')[0],
                               msg   = self.wgSave.edtComment.text(),
                               func  = 'SAVE' if not self.wgHeader.cbxAdd.isChecked() else 'PUBLISH',
                               img   = libSnapshot.default_tmp_path,
                               img_link = os.path.dirname(self.save_file))
        arNotice.ArNotice(note)

        libSnapshot.save_snapshot(self.save_file)
        return True
Beispiel #4
0
    def create_folder_structure(self):
        # CHECK inputs
        for inputs in self.inputs:
            if not inputs.currentText():
                if self.scene_steps < 5 and self.wgSaveAs.cbxSet == inputs:
                    continue
                self.set_status('Missing input: {}'.format(
                    inputs.objectName().replace('cbx', '')),
                                msg_type=2)
                return False

        self.update_file()

        # CHECK FILE
        if os.path.exists(self.save_file):
            self.set_status('PATH already exists: {}'.format(self.save_file),
                            msg_type=2)
            return False

        save_list = []

        if self.all_task in self.save_file:
            for task in self.data['rules']['TASK'][
                    self.wgSaveAs.cbxScene.currentText()]:
                new_path = self.save_file.replace(self.all_task, task)
                save_list.append(new_path)
        else:
            save_list.append(self.save_file)

        LOG.debug('Folder list {}'.format(save_list))
        for folder in save_list:
            libFunc.create_folder(folder)

        if self.new_file:
            Tank().software.scene_saveAs(self.save_file, setup_scene=True)
            libSnapshot.create_any_screenshot(self.wgSaveAs)
            tmp_img_path = libSnapshot.save_snapshot(self.save_file)

            tmp_title = os.path.basename(self.save_file).split('.')[0]
            tmp_func = 'SAVE AS'

            self.set_meta_data(self.save_file)
        else:
            try:
                self.set_open_folder(save_list[0])
            except:
                LOG.error('CANT set folder: {}'.format(save_list))
            self.set_status('Created new {}'.format(
                self.wgSaveAs.cbxScene.currentText()),
                            msg_type=1)

            tmp_img_path = 'lbl/lblCreate131'
            tmp_title = self.wgSaveAs.cbxScene.currentText()
            tmp_func = 'CREATE'

        note = arNotice.Notice(title=tmp_title,
                               msg='CREATED a new {} with folders'.format(
                                   self.wgSaveAs.cbxScene.currentText()),
                               func=tmp_func,
                               img=tmp_img_path,
                               img_link=os.path.dirname(self.save_file))
        arNotice.ArNotice(note)

        return True
Beispiel #5
0
    def setup(self, user_id=os.getenv('username')):
        self.create()

        if os.path.exists(os.path.dirname(self.user_path)):
            libFunc.create_folder(self.user_path)