예제 #1
0
파일: Popup.py 프로젝트: gonnaflyzhang/HAOC
    def load_nodes(self):
        if SCloudUtils.is_any_cloud_operation_running():
            print "Please wait for current cloud operation finish"
            self.close()
            return
        if self.accepted_index.row < 0:
            return
        source_selected_index = self.sort_filter.mapToSource(
            self.accepted_index)
        selected_item = self.sort_filter.sourceModel().itemFromIndex(
            source_selected_index)
        if selected_item.text()[-1] == '/':
            return
        selected_path = "%s.nod" % PopWidget.get_selected_path(selected_item)

        cat_name = self.pwd_for_load_nodes.childTypeCategory().name()
        file_path = '%s/%s/%s' % (HaocUtils.get_local_nodes_path(), cat_name,
                                  selected_path)

        if os.path.getsize(file_path) == 0:
            d = SCloudUtils.TDownloadNode("%s/%s" % (cat_name, selected_path))
            d.download_finished.connect(self.on_download_finished)
            d.start()
        else:
            self.load_asset_in_houdini(file_path)
        self.close()
        self.network_editor.homeToSelection()
예제 #2
0
    def on_login(self):
        access_key = self.access_key_lie.text().strip()
        secret_key = self.secret_key_lie.text().strip()
        if access_key == '' or secret_key == '':
            HaocUtils.show_message_box(
                self, "Please complete the necessary information!")
            return
        login_data_state = SCloudUtils.login_cloud(access_key, secret_key)
        if login_data_state.state != SCloudUtils.ResultDataState.SUCCESS:
            if login_data_state.state == SCloudUtils.ResultDataState.ACCESS_KEY_ERROR:
                HaocUtils.show_message_box(self, "AccessKey is not exist!")
                return
            elif login_data_state.state == SCloudUtils.ResultDataState.SECRET_KEY_ERROR:
                HaocUtils.show_message_box(self, "SecretKey is incorrect")
                return
            elif login_data_state.state == SCloudUtils.ResultDataState.BAD_NETWORK:
                HaocUtils.show_message_box(
                    self,
                    "Bad Network or something wrong ,fix your network problem and try again!"
                )
                return
            else:
                HaocUtils.show_message_box(self, "Unknown error!")
                return
        # Login success
        else:
            user_name = None
            data_state = SCloudUtils.get_user_name()
            if data_state.state != SCloudUtils.ResultDataState.SUCCESS:
                # If there is no name make one
                if data_state.state == SCloudUtils.ResultDataState.TARGET_NOT_FOUND:
                    make_name_w = MakeNameWidget(self)
                    # make_name_w.setParent(self, QtCore.Qt.Dialog)
                    make_name_w.setWindowFlags(QtCore.Qt.Dialog)
                    if make_name_w.exec_():
                        user_name = make_name_w.get_name().strip()
                    else:
                        return
                else:
                    HaocUtils.show_message_box(
                        self,
                        "Bad Network or something wrong ,fix your network problem and try again!"
                    )
            # Already has a name just get it
            else:
                user_name = data_state.data

            data = HaocUtils.Config(access_key, secret_key, user_name)
            data.save()

            asset_manage_widget = AssetMangeWidget(user_name)
            asset_manage_widget.setStyleSheet(self.styleSheet())
            asset_manage_widget.move(self.pos())
            asset_manage_widget.show()

            HaocEventFilter.HaocEventF.installHaocEventF()
            HaocUtils.is_login = True
            self.close()
예제 #3
0
파일: Popup.py 프로젝트: gonnaflyzhang/HAOC
    def on_tree_item_changed(self, item):
        new_name = item.text()
        if self.__old_name_for_rename is None or self.__old_name_for_rename == new_name:
            return
        if len(new_name) < 3:
            item.setText(self.__old_name_for_rename)
            return
        res = HaocUtils.check_name_ok(new_name)

        if res != '':
            item.setText(self.__old_name_for_rename)
            return

        if self.__old_name_for_rename[-1] == '/':
            if new_name.count('/') > 1:
                item.setText(self.__old_name_for_rename)
                return
            if new_name[-1] != '/':
                new_name = "%s/" % new_name
                item.setText(new_name)
                return
        else:
            if new_name.find('/') != -1:
                item.setText(self.__old_name_for_rename)
                return

        if self.__old_name_for_rename != item.text():
            new_local_name = "%s/%s/%s" % (HaocUtils.get_local_nodes_path(),
                                           self.get_context_name(),
                                           self.get_selected_path(item))
            old_local_name = new_local_name[:-len(item.text(
            ))] + self.__old_name_for_rename
            new_cloud_name = "%s/%s" % (self.get_context_name(),
                                        self.get_selected_path(item))
            old_cloud_name = new_cloud_name[:-len(item.text(
            ))] + self.__old_name_for_rename
            if new_local_name[-1] == "/":
                if os.path.exists(new_local_name):
                    item.setText(self.__old_name_for_rename)
                    return
                else:
                    os.rename(old_local_name, new_local_name)
            else:
                if os.path.exists("%s.nod" % new_local_name):
                    item.setText(self.__old_name_for_rename)
                    return
                else:
                    os.rename("%s.nod" % old_local_name,
                              "%s.nod" % new_local_name)
                    if os.path.exists("%s.hlp" % old_local_name):
                        os.rename("%s.hlp" % old_local_name,
                                  "%s.hlp" % new_local_name)
            com = HaocObjects.CommandItem(3,
                                          old_name=old_cloud_name,
                                          new_name=new_cloud_name)
            t_rename = SCloudUtils.TDoCommands([com])
            t_rename.start()
예제 #4
0
 def on_delete_menu(self):
     if SCloudUtils.is_any_cloud_operation_running():
         print "Please wait for current cloud operation finish"
         return
     selected_path = HaocObjects.get_selected_path(self.get_current_item())
     local_path = "%s/%s" % (HaocUtils.get_local_nodes_path(),
                             selected_path)
     if selected_path[-1] == '/':
         os.rmdir(local_path)
     else:
         os.remove("%s.nod" % local_path)
         if os.path.exists("%s.hlp" % local_path):
             os.remove("%s.hlp" % local_path)
     com = HaocObjects.CommandItem(2, path=selected_path)
     t_delete = SCloudUtils.TDoCommands([com])
     t_delete.start()
     index = self.tree_view.currentIndex()
     self.tree_view.sort_filter.removeRow(index.row(), index.parent())
예제 #5
0
    def on_tree_dou_clicked(self, index):
        if SCloudUtils.is_any_cloud_operation_running():
            print "Please wait for current cloud operation finish"
            return
        index = self.tree_view.sort_filter.mapToSource(index)
        item = self.tree_view.sort_filter.sourceModel().itemFromIndex(index)
        common_path = HaocObjects.get_selected_path(item)
        if common_path[-1] == '/':
            return
        else:
            common_path = "%s.nod" % common_path

        local_path = "%s/%s" % (HaocUtils.get_local_nodes_path(), common_path)
        if os.path.getsize(local_path) == 0:
            d = SCloudUtils.TDownloadNode(common_path)
            d.download_finished.connect(self.on_download_finished)
            d.start()
            self.__downloading_item = item
예제 #6
0
파일: Popup.py 프로젝트: gonnaflyzhang/HAOC
 def on_rename_menu(self):
     if SCloudUtils.is_any_cloud_operation_running():
         print "Please wait for current cloud operation finish"
         return
     index = self.tree_view.currentIndex()
     source_index = self.sort_filter.mapToSource(index)
     selected_item = self.sort_filter.sourceModel().itemFromIndex(
         source_index)
     self.__old_name_for_rename = selected_item.text()
     self.tree_view.edit(index)
예제 #7
0
    def on_apply_help_change(self):
        txt = self.help_tee.toPlainText().strip()
        if txt == '':
            return
        sel_item = self.get_current_item()
        if sel_item is None:
            return
        sel_path = HaocObjects.get_selected_path(sel_item)
        if sel_path[-1] == '/':
            return
        if SCloudUtils.is_any_cloud_operation_running():
            print "Please wait for current cloud operation finish"
            return
        local_path = "%s/%s.hlp" % (HaocUtils.get_local_nodes_path(), sel_path)

        with codecs.open(local_path, 'w', 'utf-8') as f:
            f.write(txt)
        upload_hlp_t = SCloudUtils.TUploadHlp(sel_path)
        upload_hlp_t.start()
예제 #8
0
 def on_accept(self):
     name = self.name_lie.text().strip()
     if len(name) < 3:
         HaocUtils.show_message_box(self,
                                    "Name must at least have 3 letters!")
         return
     set_name_data_state = SCloudUtils.set_user_name(name)
     if set_name_data_state.state != SCloudUtils.ResultDataState.SUCCESS:
         HaocUtils.show_message_box(
             self,
             "Bad Network or something wrong ,fix your network problem and try again!"
         )
     else:
         self.accept()
예제 #9
0
import hou
import sinastorage
from haoc import HaocUtils,DBUtils,SCloudUtils
from haoc import HaocEventFilter

hou.putenv("HAOCROOTPATH", HaocUtils.get_root_path())

config = HaocUtils.Config.read()
if not (config.ak=='' or config.sk==''):
	sinastorage.setDefaultAppInfo(config.ak,config.sk)
	HaocEventFilter.HaocEventF.installHaocEventF()
	if DBUtils.is_launch_with_sync():
		SCloudUtils.sync_data(False)
예제 #10
0
파일: Popup.py 프로젝트: gonnaflyzhang/HAOC
    def save_nodes(self):
        input_name = self.asset_name.text().strip()
        if len(input_name) < 3:
            QtWidgets.QMessageBox.warning(
                hou.qt.mainWindow(), "Input Error",
                "The number of letters of Asset name must at least have 3")
            return
        input_error = HaocUtils.check_name_ok(input_name)
        if input_error != '':
            QtWidgets.QMessageBox.warning(
                hou.qt.mainWindow(), "Input Error",
                "File name is not up to standard,please remove the stuff below from your input:\n%s"
                % input_error)
            return

        selected_path = ""
        index = self.tree_view.currentIndex()
        index = self.sort_filter.mapToSource(index)
        selected_item = self.sort_filter.sourceModel().itemFromIndex(index)
        if selected_item:
            selected_path = PopWidget.get_selected_folder(selected_item)
        asset_upload_path = selected_path + input_name
        parent = hou.selectedItems()[0].parent()
        cat_name = parent.childTypeCategory().name()
        local_path = '%s/data/%s/nodes/%s/%s' % (HaocUtils.get_root_path(),
                                                 HaocUtils.Config.get_ak(),
                                                 cat_name, asset_upload_path)
        cloud_path = '%s/%s' % (cat_name, asset_upload_path)

        if input_name[-1] == "/":
            if not os.path.exists(local_path):
                os.makedirs(local_path)
        else:
            if os.path.exists("%s.nod" % local_path):
                button_code = HaocUtils.show_question_box(
                    self,
                    "This asset is already exist,do you want to replace it?")
                if button_code != QtWidgets.QMessageBox.Yes:
                    return

            # Check for SopNode HardLocked status
            if len(hou.selectedNodes()) > 1:
                locked_nodes = []
                if self.network_editor.pwd().childTypeCategory(
                ) == hou.sopNodeTypeCategory():
                    for node in hou.selectedNodes():
                        if isinstance(node,
                                      hou.SopNode) and node.isHardLocked():
                            locked_nodes.append(node)
                if len(locked_nodes) > 0:
                    text = "Detected these selected nodes have had HardLocked,thus will cause asset become large, " \
                        "do you want to unlock those nodes?\n%s" % "\n".join([x.name() for x in locked_nodes])
                    button_code = HaocUtils.show_question_box(self, text)
                    if button_code == QtWidgets.QMessageBox.Cancel:
                        return
                    if button_code == QtWidgets.QMessageBox.Yes:
                        for node in locked_nodes:
                            node.setHardLocked(False)

            if not os.path.exists(os.path.dirname(local_path)):
                os.makedirs(os.path.dirname(local_path))
            parent.saveItemsToFile(hou.selectedItems(), "%s.nod" % local_path,
                                   self.hda_fall_backs.isChecked())
            if self.comments.toPlainText().strip() != '':
                with codecs.open("%s.hlp" % local_path, 'w',
                                 'utf-8') as comments_file:
                    comments_file.write(self.comments.toPlainText())

        # Put folder or file on cloud
        command = HaocObjects.CommandItem(1, path=cloud_path)
        commands_t = SCloudUtils.TDoCommands([command])
        commands_t.start()
예제 #11
0
 def on_sync():
     if SCloudUtils.is_any_cloud_operation_running():
         print "Please wait for current cloud operation finish"
         return
     SCloudUtils.sync_data()