Пример #1
0
    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_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()
Пример #3
0
    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)
Пример #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
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
Пример #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()