Beispiel #1
0
 def validte_asset_publish(self, file, item):
     studio_asset = studioAsset.Asset()
     valid = studio_asset.had_valid(file)
     if valid:
         return
     item.setFlags(QtCore.Qt.ItemIsSelectable |
                   QtCore.Qt.ItemIsDragEnabled | QtCore.Qt.ItemIsUserCheckable)
Beispiel #2
0
 def rename_model(self, lineedit):
     studio_asset = studioAsset.Asset()
     if not self.currnet_publish:
         self.studio_print.display_warning(
             'Not selected any shader or shader not valid.')
         return
     current_image = studio_asset.get_image(self.currnet_publish)
     new_name = '%s' % lineedit.text()
     model_format = os.path.splitext(self.currnet_publish)[-1]
     self.folder.rename(folder_path=self.currnet_publish,
                        name='%s%s' % (new_name, model_format))
     image_format = os.path.splitext(current_image)[-1]
     self.folder.rename(folder_path=current_image,
                        name='%s%s' % (new_name, image_format))
     self.load_current_folder(self.treewidget)
Beispiel #3
0
    def builds(self, tag, listwidge, *args):
        current_items = listwidge.selectedItems()
        if not current_items:
            self.clear_publish()
            return
        self.button_publish.hide()
        self.button_build.show()
        self.groupbox_path.hide()
        self.label_filepath.hide()
        self.lineedit_filepath.hide()
        self.pushbutton_filepath.hide()
        self.label_imagepath.hide()
        self.lineedit_imagepath.hide()
        self.pushbutton_imagepath.hide()
        publish_paths = []
        for each_item in current_items:
            publish_paths.append(str(each_item.toolTip()))
        self.currnet_publish = publish_paths[-1]
        studio_asset = studioAsset.Asset(paths=publish_paths)
        data = studio_asset.create(False, 'reference', fake=True)
        data = data[data.keys()[0]]
        comment = [data['comment'], 'author : %s' % data['author'], data['tag'],
                   data['#copyright'], 'user : %s' % data['user'], data['created_date']]
        self.textedit_history.setText('\n'.join(comment))
        self.textedit_history.setReadOnly(True)
        self.lineedit_label.setText(os.path.basename(
            os.path.splitext(publish_paths[-1])[0]))
        self.asset.image_to_button(
            path=studio_asset.get_image(publish_paths[-1]))

        if tag == 'build':
            if self.standalone:
                if not self.maya_path:
                    QtWidgets.QMessageBox.warning(
                        self, 'Warning', 'Please set the maya path!...',
                        QtWidgets.QMessageBox.Ok)
                    self.studio_print.display_warning(
                        'Please set the maya path!...')
                    return
                if not os.path.isdir(self.maya_path):
                    QtWidgets.QMessageBox.warning(
                        self, 'Warning', 'Not such maya path!...\n%s' % self.maya_path,
                        QtWidgets.QMessageBox.Ok)
                    self.studio_print.display_warning(
                        'Not such maya path!...\n%s' % self.maya_path)
                    return
            if not self.create_type or self.create_type == 'None':
                QtWidgets.QMessageBox.warning(
                    self, 'Warning', 'Please set the create type [import or reference]!...',
                    QtWidgets.QMessageBox.Ok)
                self.studio_print.display_warning(
                    'Please set the create type [import or reference]!...')
                return

            if not self.maya_type or self.maya_type == 'None':
                QtWidgets.QMessageBox.warning(
                    self, 'Warning', 'Please set the maya file type [mayaAscii or mayaBinary]!...',
                    QtWidgets.QMessageBox.Ok)
                self.studio_print.display_warning(
                    'Please set the maya file type [mayaAscii or mayaBinary]!...')
                return

            if self.standalone:
                QtWidgets.QApplication.setOverrideCursor(
                    QtCore.Qt.CustomCursor.WaitCursor)
                result = studio_asset.create(
                    'standalone', self.create_type, maya_type=self.maya_type,
                    maya_path=self.maya_path, output_path=self.output_path)
                message = 'maya file created in - {}'.format(result)
                self.studio_print.display_info(message)
                QtWidgets.QApplication.restoreOverrideCursor()
                if result:
                    QtWidgets.QMessageBox.information(
                        self, 'Information', message, QtWidgets.QMessageBox.Ok)
                    if platform.system() == 'Windows':
                        try:
                            os.startfile(os.path.dirname(result))
                        except:
                            pass
                    if platform.system() == 'Linux':
                        try:
                            os.system('xdg-open \"%s\"' %
                                      os.path.dirname(result))
                        except:
                            pass
                else:
                    QtWidgets.QMessageBox.warning(
                        self, 'Warning', 'maya file creation faild!...',
                        QtWidgets.QMessageBox.Ok)
            else:
                QtWidgets.QApplication.setOverrideCursor(
                    QtCore.Qt.CustomCursor.WaitCursor)
                result = studio_asset.create(
                    'maya', self.create_type)
                QtWidgets.QApplication.restoreOverrideCursor()
Beispiel #4
0
    def publish(self):
        current_items = self.treewidget.selectedItems()
        if not current_items:
            QtWidgets.QMessageBox.warning(
                self, 'Warning', 'Not found any folder selection.\nSelect the folder and try!...',
                QtWidgets.QMessageBox.Ok)
            self.studio_print.display_warning(
                'Not found any folder selection.')
            return
        current_path = str(current_items[-1].toolTip(0))
        if not os.path.isdir(current_path):
            QtWidgets.QMessageBox.warning(
                self, 'Warning', 'Not found such Publish directory!...%s' % current_path,
                QtWidgets.QMessageBox.Ok)
            self.studio_print.display_warning(
                'Not found such Publish directory!...%s' % current_path)
            return
        if not self.source_file:
            QtWidgets.QMessageBox.warning(
                self, 'Warning', 'Not found any source file!...', QtWidgets.QMessageBox.Ok)
            self.studio_print.display_warning('Not found any source file!...')
            return
        label = self.asset.lineedit_label.text()
        if not label:
            QtWidgets.QMessageBox.warning(
                self, 'Warning', 'Not found the Name of the the Publish!...',
                QtWidgets.QMessageBox.Ok)
            self.studio_print.display_warning(
                'Not found the Name of the the Publish!...')
            return  # add condition for mutlipe object

        self.source_file_path = os.path.abspath(
            str(self.lineedit_filepath.text())).replace('\\', '/')
        studio_asset = studioAsset.Asset(
            path=self.source_file_path, image=self.q_image)
        if studio_asset.had_file(current_path, label):
            replay = QtWidgets.QMessageBox.warning(
                self, 'Warning', 
                'Already a file with the same name in the publish\n\"%s\"\nIf you want to overwrite press Yes' % label,
                QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
            self.studio_print.display_warning(
                'Already a file with the same name in the publish')
            if replay != QtWidgets.QMessageBox.Yes:
                return
        user_comment = self.asset.textedit_history.toPlainText()
        result = studio_asset.save(
            current_path, label, user_comment=user_comment)
        self.load_current_folder(self.treewidget)
        self.clear_publish()
        self.source_file, self.source_file_path = False, None

        message = 'Publish success!...'
        if False in result:
            message = 'Publish Failed!...\n%s\n%s' % (
                result[False], '[more details and debugging [email protected]]')
            QtWidgets.QMessageBox.critical(
                self, 'Failed', message, QtWidgets.QMessageBox.Ok)
            self.studio_print.display_info(message)
            return
        QtWidgets.QMessageBox.information(
            self, 'Information', message, QtWidgets.QMessageBox.Ok)
        self.studio_print.display_info(message)