def refresh_tree(self): context = self.get_context_name() self.model.clear() HaocUtils.setup_tree_model( self.model, "%s/data/%s/nodes/%s" % (HaocUtils.get_root_path(), HaocUtils.Config.get_ak(), context)) self.model.setHorizontalHeaderLabels(["%s/" % context])
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()
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()
def load_asset_in_houdini(self, file_path): try: hou.clearAllSelected() self.pwd_for_load_nodes.loadItemsFromFile(file_path, True) with hou.undos.disabler(): self.move_nodes_to_clicked_position(hou.selectedItems(), self.pos_for_load_nodes) except hou.PermissionError as e: HaocUtils.show_message_box(self, e.instanceMessage()) except hou.OperationFailed as e: HaocUtils.show_message_box(self, e.description()) # If load failed it can be the asset damaged, so make it size 0 for nex time download open(file_path, 'w').close() except hou.LoadWarning as e: print e.description()
def on_sel_changed(self, selected, deselected): indexes = selected.indexes() if len(indexes) < 1: return index = self.tree_view.sort_filter.mapToSource(indexes[0]) selected_item = self.tree_view.source_model.itemFromIndex(index) selected_path = HaocObjects.get_selected_path(selected_item) self.tree_view.source_model.setHorizontalHeaderLabels([ selected_path if selected_path[-1] == '/' else selected_path + '.nod' ]) # Show help stuff if selected_path[-1] != '/': text = '' file_path = '%s/data/%s/nodes/%s.hlp' % (HaocUtils.get_root_path(), HaocUtils.Config.get_ak(), selected_path) if os.path.exists(file_path): if os.path.getsize(file_path) == 0: self.help_tee.setDisabled(True) else: self.help_tee.setDisabled(False) with open(file_path, 'r') as comments_file: text = comments_file.read() else: self.help_tee.setDisabled(False) self.help_tee.setText(text) else: self.help_tee.setDisabled(True) self.help_tee.setText('')
def __init__(self, parent=None): QtWidgets.QDialog.__init__(self, parent) loader = QtUiTools.QUiLoader() self.ui = loader.load(HaocUtils.get_root_path() + '/ui/MakeName.ui') main_layout = QtWidgets.QVBoxLayout() main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(self.ui) self.setLayout(main_layout) self.setGeometry(self.ui.geometry()) self.setWindowModality(QtCore.Qt.ApplicationModal) self.move(self.cursor().pos() - QtCore.QPoint(self.size().width() / 2, self.size().height() / 2)) self.setFixedSize(self.width(), self.height()) self.name_lie = self.ui.findChild(QtWidgets.QLineEdit, "name_lie") self.accept_btn = self.ui.findChild(QtWidgets.QPushButton, "accept_btn") self.accept_btn.clicked.connect(self.on_accept) self.move( parent.mapToGlobal( QtCore.QPoint((parent.width() - self.width()) / 2, (parent.height() - self.height()) / 2)))
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()
def fun(_time_out): if self.lis is not None: self.lis = [] bucket = SCSBucket(BUCKET_NAME, timeout=_time_out) items_generator = bucket.listdir(prefix='haoc/nodes/', limit=10000) access_key = HaocUtils.Config.get_ak() for item in items_generator: common_name = item[0][11:] local_name = "%s/data/%s/nodes/%s" % ( HaocUtils.get_root_path(), access_key, common_name) if self.lis is not None: if common_name[-1] == '/' or common_name[-4:] == '.nod': self.lis.append(common_name) if common_name[-1] == '/': if not os.path.exists(local_name): os.makedirs(local_name) elif common_name[-4:]: if os.path.exists(local_name): lt = int(os.path.getmtime("%s.nod" % local_name[:-4])) ct = int( bucket.info( "%s.nod" % item[0][:-4]).get('metadata').get('lmt')) # Compare local file modified time with cloud file modified time if lt < ct: open(local_name, "w").close() if is_manual_sync: print "Updated: %s" % common_name else: if not os.path.exists(os.path.dirname(local_name)): os.makedirs(os.path.dirname(local_name)) open(local_name, "w").close() if is_manual_sync: print "Created: %s" % common_name
def on_sel_changed(self, selected, deselected): indexes = selected.indexes() if len(indexes) < 1: return index = self.sort_filter.mapToSource(indexes[0]) selected_item = self.sort_filter.sourceModel().itemFromIndex(index) selected_path = PopWidget.get_selected_path(selected_item) self.model.setHorizontalHeaderLabels([ "%s/%s" % (self.get_context_name(), selected_path if selected_path[-1] == '/' else selected_path + '.nod') ]) # Show help stuff text = '' if selected_path[-1] != '/': file_path = '%s/data/%s/nodes/%s/%s.hlp' % ( HaocUtils.get_root_path(), HaocUtils.Config.get_ak(), self.get_context_name(), selected_path) if os.path.exists(file_path): with open(file_path, 'r') as comments_file: text = comments_file.read() if text != '': self.help_widget = HelpWidget(text, self) self.help_widget.setStyleSheet(self.styleSheet()) self.help_widget.show() elif self.help_widget is not None and self.help_widget.isVisible(): self.help_widget.close()
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) self.is_shift_hold = False self.help_widget = None self.network_editor = None self.mouse_Press_pos = QtCore.QPoint() self.can_move = False self.accepted_index = None self.pwd_for_load_nodes = None self.pos_for_load_nodes = None self.__old_name_for_rename = None self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.NoDropShadowWindowHint) self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) loader = QtUiTools.QUiLoader() self.ui = loader.load(HaocUtils.get_root_path() + '/ui/Popup.ui') self.title = self.ui.findChild(QtWidgets.QLabel, "title") self.upload_widgets = self.ui.findChild(QtWidgets.QWidget, "upload_widgets") self.comments = self.ui.findChild(QtWidgets.QTextEdit, "comments") self.splitter = self.ui.findChild(QtWidgets.QSplitter, "splitter") self.upload_btn = self.ui.findChild(QtWidgets.QPushButton, "upload") self.search_bar = self.ui.findChild(QtWidgets.QLineEdit, "search_bar") self.asset_name = self.ui.findChild(QtWidgets.QLineEdit, "asset_name") self.tree_view = self.ui.findChild(QtWidgets.QTreeView, "tree_view") self.hda_fall_backs = self.ui.findChild(QtWidgets.QCheckBox, "hda_fall_backs") self.splitter.setSizes([0]) self.upload_btn.clicked.connect(self.on_upload) self.search_bar.textChanged.connect(self.on_search_changed) self.tree_view.setEditTriggers( QtWidgets.QAbstractItemView.NoEditTriggers) self.tree_view.doubleClicked.connect(self.on_tree_dou_clicked) self.tree_view.collapsed.connect(self.on_resize_column) self.tree_view.expanded.connect(self.on_resize_column) self.tree_view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.tree_view.customContextMenuRequested.connect(self.open_menu) self.model = QtGui.QStandardItemModel() self.model.itemChanged.connect(self.on_tree_item_changed) self.sort_filter = HaocObjects.TreeViewSortFilterProxyModel() self.sort_filter.setSourceModel(self.model) self.tree_view.setModel(self.sort_filter) self.selection_model = self.tree_view.selectionModel() self.selection_model.selectionChanged.connect(self.on_sel_changed) main_layout = QtWidgets.QVBoxLayout() main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(self.ui) self.setLayout(main_layout) self.setGeometry(self.ui.geometry())
def run(self): local_path = "%s/%s.hlp" % (HaocUtils.get_local_nodes_path(), self.path) def fun(_time_out): cloud_path = "haoc/nodes/%s.hlp" % self.path bucket = SCSBucket(BUCKET_NAME, timeout=_time_out) bucket.putFile(cloud_path, local_path) catch_result(fun, 3, 2)
def __on_data_to_local_done(d): if d.state == ResultDataState.SUCCESS: local_lis = [] HaocUtils.get_local_file_list(local_lis, HaocUtils.get_root_path()) diff_set = set(local_lis) - set(d.data) for x in diff_set: f = "%s/%s" % (HaocUtils.get_local_nodes_path(), x) os.remove(f) if os.path.exists("%s.hlp" % f[:-4]): os.remove("%s.hlp" % f[:-4]) if is_manual_sync: print "\n++++++++++ Sync done ++++++++++\n" Trumpet.singleton.sync_done.emit() DBUtils.set_dirty(False) else: if is_manual_sync: print "\n++++++++++ Sync failed ++++++++++\n" global is_synchronizing is_synchronizing = False
def __init__(self, user_name='', parent=None): QtWidgets.QWidget.__init__(self, parent) self.setWindowTitle("Assets Manager") self.__old_name_for_rename = None self.__downloading_item = None loader = QtUiTools.QUiLoader() loader.registerCustomWidget(HaocObjects.HaocTreeView) self.ui = loader.load(HaocUtils.get_root_path() + '/ui/AssetMange.ui') self.tree_view = self.ui.findChild(HaocObjects.HaocTreeView, "tree_view") self.search_bar = self.ui.findChild(QtWidgets.QLineEdit, "search_bar") self.user_name = self.ui.findChild(QtWidgets.QLabel, "user_name") self.logout = self.ui.findChild(QtWidgets.QPushButton, "logout") self.sync = self.ui.findChild(QtWidgets.QPushButton, "sync") self.help_tee = self.ui.findChild(QtWidgets.QTextEdit, "help") self.apply_help_change = self.ui.findChild(QtWidgets.QPushButton, "apply_help_change") self.sync_while_launch = self.ui.findChild(QtWidgets.QCheckBox, "sync_while_launch") self.help_tee.setDisabled(True) self.sync_while_launch.setChecked(DBUtils.is_launch_with_sync()) self.sync_while_launch.stateChanged.connect(self.on_swl_changed) self.logout.clicked.connect(self.on_logout) self.sync.clicked.connect(self.on_sync) self.apply_help_change.clicked.connect(self.on_apply_help_change) self.user_name.setText(user_name) self.tree_view.doubleClicked.connect(self.on_tree_dou_clicked) self.tree_view.source_model.itemChanged.connect( self.on_tree_item_changed) self.tree_view.selectionModel() self.selection_model = self.tree_view.selectionModel() self.selection_model.selectionChanged.connect(self.on_sel_changed) self.tree_view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.tree_view.customContextMenuRequested.connect(self.open_menu) self.search_bar.textChanged.connect(self.on_search_changed) main_layout = QtWidgets.QVBoxLayout() main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(self.ui) self.setLayout(main_layout) self.setGeometry(self.ui.geometry()) self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) HaocUtils.ObjectsHolder.add(self) AssetMangeWidget.is_occupied = True SCloudUtils.Trumpet.singleton.sync_done.connect(self.on_done) self.refresh_tree()
def run(self): local_path = "%s/data/%s/nodes/%s" % ( HaocUtils.get_root_path(), HaocUtils.Config.get_ak(), self.path) def fun(): cloud_path = "haoc/nodes/%s" % self.path bucket = SCSBucket(BUCKET_NAME) # info = bucket.info(cloud_path) total_size = 0 response = bucket[cloud_path] CHUNK = 16 * 1024 download_size = 0 with open(local_path, 'wb') as fp: while True: chunk = response.read(CHUNK) if download_size == 0: total_size = long(response.info().dict.get( 'content-length', 0)) download_size += CHUNK self.progress_bar.set_progress(download_size, total_size) if not chunk: break fp.write(chunk) if os.path.exists("%s.hlp" % local_path[:-4]): response = bucket["%s.hlp" % cloud_path[:-4]] with open("%s.hlp" % local_path[:-4], 'wb') as fp: while True: chunk = response.read(CHUNK) if not chunk: break fp.write(chunk) data_state = catch_result(fun, 2) if data_state.state != ResultDataState.SUCCESS: if data_state.state == ResultDataState.TARGET_NOT_FOUND: os.remove(local_path) if os.path.exists("%s.hlp" % local_path[:-4]): os.remove("%s.hlp" % local_path[:-4]) else: with open(local_path, 'wb'): pass if os.path.exists("%s.hlp" % local_path[:-4]): with open("%s.hlp" % local_path[:-4], 'w'): pass data_state.data = local_path self.download_finished.emit(data_state)
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
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())
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()
def delete(self, com, time_out): cloud_path = "haoc/nodes/%s" % com.path bucket = SCSBucket(BUCKET_NAME, timeout=time_out) if cloud_path[-1] == '/': del bucket[cloud_path] else: shall_do = True if self.from_agenda: try: bucket["%s.nod" % cloud_path] except sinastorage.bucket.KeyNotFound: return else: info = bucket.info("%s.nod" % cloud_path) ct = HaocUtils.utc_to_local_stamp(info['modify']) if com.op_time < ct: shall_do = False if shall_do: del bucket["%s.nod" % cloud_path] del bucket["%s.hlp" % cloud_path]
def create(self, com): if com.path[-1] != '/': self.new_item_start.emit(os.path.basename(com.path)) cloud_path = "haoc/nodes/%s" % com.path bucket = SCSBucket(BUCKET_NAME) local_path = "%s/data/%s/nodes/%s" % ( HaocUtils.get_root_path(), HaocUtils.Config.get_ak(), com.path) if cloud_path[-1] == '/': bucket.put(cloud_path, '') else: shall_upload = True if not os.path.exists("%s.nod" % local_path): print "File not found:%s" % local_path return lt = int(os.path.getmtime("%s.nod" % local_path)) if self.from_agenda: try: bucket["%s.nod" % cloud_path] except sinastorage.bucket.KeyNotFound: pass else: info = bucket.info("%s.nod" % cloud_path) ct = int(info.get('metadata').get('lmt')) if lt < ct: shall_upload = False if shall_upload: bucket.putFile("%s.nod" % cloud_path, "%s.nod" % local_path, self.call_back) bucket.update_meta("%s.nod" % cloud_path, {'lmt': str(lt)}) bucket.update_meta("%s.nod" % cloud_path, {'hver': hou.applicationVersionString()}) if os.path.exists("%s.hlp" % local_path): bucket.putFile("%s.hlp" % cloud_path, "%s.hlp" % local_path) else: open("%s.nod" % local_path, 'w').close()
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) self.setWindowTitle("Login") loader = QtUiTools.QUiLoader() self.ui = loader.load(HaocUtils.get_root_path() + '/ui/Login.ui') self.access_key_lie = self.ui.findChild(QtWidgets.QLineEdit, "access_key_lie") self.secret_key_lie = self.ui.findChild(QtWidgets.QLineEdit, "secret_key_lie") self.login_btn = self.ui.findChild(QtWidgets.QPushButton, "accept_btn") self.link_lab = self.ui.findChild(QtWidgets.QLabel, "link") self.login_btn.clicked.connect(self.on_login) self.link_lab.linkActivated.connect(self.on_clicked_link) main_layout = QtWidgets.QVBoxLayout() main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(self.ui) self.setLayout(main_layout) self.setGeometry(self.ui.geometry()) self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) HaocUtils.ObjectsHolder.add(self) LoginWidget.is_occupied = True
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()
def on_logout(self): data = HaocUtils.Config() data.save() HaocEventFilter.HaocEventF.uninstallHaocEventF() HaocUtils.is_login = False self.close()
def refresh_tree(self): self.tree_view.source_model.clear() HaocUtils.setup_tree_model( self.tree_view.source_model, "%s/data/%s/nodes/" % (HaocUtils.get_root_path(), HaocUtils.Config.get_ak())) self.tree_view.source_model.setHorizontalHeaderLabels([""])
import hou, sys from haoc import HaocUtils, PicToTxt from haoc.ui import Login from haoc.ui import AssetManage click_pos = hou.qt.mainWindow().cursor().pos() if sys.argv.count('haoc') > 0: if HaocUtils.Config.get_ak() == '' or HaocUtils.Config.get_sk() == '': if not Login.LoginWidget.is_occupied: login = Login.LoginWidget() login.setStyleSheet(hou.qt.styleSheet()) login.move(click_pos) login.show() else: if not AssetManage.AssetMangeWidget.is_occupied: asset_manage_w = AssetManage.AssetMangeWidget( HaocUtils.Config.get_name()) asset_manage_w.setStyleSheet(hou.qt.styleSheet()) asset_manage_w.move(click_pos) asset_manage_w.show() elif sys.argv.count('about_author') > 0: path = "%s/about/author.emo" % (HaocUtils.get_root_path()) print PicToTxt.get_txt(path)
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)
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()