예제 #1
0
파일: tank.py 프로젝트: ziranjuanchow/plex
 def set_data(self, path, key, value):
     if os.path.exists(path):
         tmp_content = self.get_yml_file(path)
     else:
         tmp_content = {}
         pipefunc.create_folder(path)
     tmp_content[key] = value
     self.set_yml_file(path, tmp_content)
예제 #2
0
def save_snapshot(rlt_path, src_path=DEFAULT_PATH):
    img = QtGui.QImage()
    img.load(src_path)
    thumbnail_extension = '.' + Tank().data_project['EXTENSION']['thumbnail']

    tmpDir = os.path.dirname(
        rlt_path) + '/' + Tank().data_project['META']['dir']
    rlt_path = tmpDir + "/" + os.path.basename(rlt_path).split(
        ".")[0] + thumbnail_extension

    pipefunc.create_folder(rlt_path)
    img.save(rlt_path, format=thumbnail_extension)
    remove_tmp_img(src_path)
    return rlt_path
예제 #3
0
    def save_file_path(self):
        # USE ADDITIONAL PUBLISH SCRIPTS
        if self.wgHeader.cbxAdd.isChecked(): self.update_version()

        try:
            Tank().software.scene_save_as(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['project']['STATUS']['publish']))
            snapshot.save_snapshot(tmpCopyWork)
            self.set_meta_data(tmpCopyWork)

            found_version = re.search(self.data['project']['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['project']['STATUS']['work'] in self.save_file:
                self.save_publish_file = self.save_publish_file.replace(
                    self.data['project']['STATUS']['work'],
                    self.data['project']['STATUS']['publish'])
            else:
                LOG.error("FAIL : NO {} in path : {}".format(
                    self.data['project']['STATUS']['work'],
                    self.save_publish_file),
                          exc_info=True)
                return False

            pipefunc.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)
            snapshot.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=snapshot.DEFAULT_PATH,
            img_link=os.path.dirname(self.save_file))
        arNotice.ArNotice(note)

        snapshot.save_snapshot(self.save_file)
        return True
예제 #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 Tank().data_project['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:
            pipefunc.create_folder(folder)

        if self.new_file:
            Tank().software.scene_save_as(self.save_file, setup_scene=True)
            snapshot.create_any_screenshot(self.wgSaveAs)
            tmp_img_path = snapshot.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/lbl_create'
            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
예제 #5
0
파일: users.py 프로젝트: ziranjuanchow/plex
    def setup(self, user_id=USER):
        self.create()

        if os.path.exists(os.path.dirname(self.sandbox_path)):
            pipefunc.create_folder(self.sandbox_path)