Exemplo n.º 1
0
    def load(self):
        try:
            check_backend()
        except Exception as e:
            print_stack()
            self.GetParent().GetParent().error_message(format(e))
            return

        try:
            # update local disk state
            self.manager_module.LoadState()

            self.modules = self.manager_module.Synchronize()
        except Exception as e:
            print_stack()
            wx.MessageBox(
                format(e),
                'Synchronization with kipartbase failed, check your connection and try again',
                wx.OK | wx.ICON_ERROR)

        #self.modules = self.manager_module.
        #self.modules =  self.resource_module.Synchronize()

        self.loadLibraries()
        self.loadModules()
Exemplo n.º 2
0
    def loadStorages(self):
        try:
            check_backend()
        except Exception as e:
            print_stack()
            self.GetParent().GetParent().error_message(format(e))
            return

        # clear all
        self.tree_storages_manager.ClearItems()
        
        # load storages
        storages = rest.api.find_storages(**self.storages_filter.query_filter())

        # load categories
        categories = {}
        for storage in storages:
            if storage.category:
                category_name = storage.category.path
            else:
                category_name = "/"

            if category_name not in categories:
                categories[category_name] = DataModelCategoryPath(storage.category)
                self.tree_storages_manager.AppendItem(None, categories[category_name])
            self.tree_storages_manager.AppendItem(categories[category_name], DataModelStorage(storage))
        
        for category in categories:
            self.tree_storages_manager.Expand(categories[category])
Exemplo n.º 3
0
    def loadCategories(self):
        try:
            check_backend()
        except Exception as e:
            print_stack()
            self.GetParent().GetParent().error_message(format(e))
            return

        # clear all
        self.tree_categories_manager.ClearItems()
        
        # load categories
        categories = rest.api.find_storages_categories()

        # load tree
        to_add = []
        id_category_map = {}
        for category in categories:
            to_add.append(category)
        while len(to_add)>0:
            category = to_add[0]
            id_category_map[category.id] = DataModelCategory(category)
            to_add.pop(0)
            
            # add to symbol
            if category.parent:
                self.tree_categories_manager.AppendItem(id_category_map[category.parent.id], id_category_map[category.id])
            else:
                self.tree_categories_manager.AppendItem(None, id_category_map[category.id])
            
            # load childs
            if category.childs:
                for child in category.childs:
                    to_add.append(child)
Exemplo n.º 4
0
    def loadLibraries(self):
        try:
            check_backend()
        except Exception as e:
            print_stack()
            self.GetParent().GetParent().error_message(format(e))
            return

        self.tree_libraries_manager.SaveState()

        # load libraries tree
        for module_path in self.modules:
            # decompose path
            folders = []
            library_path = os.path.dirname(module_path)
            path = os.path.dirname(library_path)
            library_name = os.path.basename(library_path)
            while path != '' and path != '/':
                folders.insert(0, path)
                path = os.path.dirname(path)

            for folder in folders:
                pathobj = self.tree_libraries_manager.FindPath(folder)
                if self.tree_libraries_manager.DropStateObject(
                        pathobj) == False:
                    self.tree_libraries_manager.AppendPath(folder)

            path = os.path.dirname(library_path)
            libraryobj = self.tree_libraries_manager.FindLibrary(
                path, library_name)
            if self.tree_libraries_manager.DropStateObject(
                    libraryobj) == False:
                self.tree_libraries_manager.AppendLibrary(path, library_name)

        # add folders with no library inside
        for folder in self.file_manager_module.folders:
            if re.compile("^.*\.module$").match(
                    os.path.normpath(os.path.abspath(folder))):
                path = os.path.dirname(folder)
                library_name = os.path.basename(folder)
                libraryobj = self.tree_libraries_manager.FindLibrary(
                    path, library_name)
                if self.tree_libraries_manager.DropStateObject(
                        libraryobj) == False:
                    self.tree_libraries_manager.AppendLibrary(
                        path, library_name)
            else:
                pathobj = self.tree_libraries_manager.FindPath(folder)
                if self.tree_libraries_manager.DropStateObject(
                        pathobj) == False:
                    self.tree_libraries_manager.AppendPath(folder)

        self.tree_libraries_manager.PurgeState()
Exemplo n.º 5
0
    def load(self):
        try:
            check_backend()
        except Exception as e:
            print_stack()
            self.GetParent().GetParent().error_message(format(e))
            return

        try:
            self.loadManufacturers()
        except Exception as e:
            print_stack()
            wx.MessageBox(format(e), 'Error', wx.OK | wx.ICON_ERROR)
Exemplo n.º 6
0
    def loadManufacturers(self):
        try:
            check_backend()
        except Exception as e:
            print_stack()
            self.GetParent().GetParent().error_message(format(e))
            return

        self.tree_manufacturers_manager.ClearItems()

        # retrieve categories
        manufacturers = rest.api.find_manufacturers()

        for manufacturer in manufacturers:
            self.tree_manufacturers_manager.AppendItem(
                None, DataModelManufacturer(manufacturer))
Exemplo n.º 7
0
    def loadDistributors(self):
        try:
            check_backend()
        except Exception as e:
            print_stack()
            self.GetParent().GetParent().error_message(format(e))
            return

        self.tree_distributors_manager.ClearItems()

        # retrieve categories
        distributors = rest.api.find_distributors()

        for distributor in distributors:
            self.tree_distributors_manager.AppendItem(
                None, DataModelDistributor(distributor))
Exemplo n.º 8
0
    def loadModules(self):
        try:
            check_backend()
        except Exception as e:
            print_stack()
            self.GetParent().GetParent().error_message(format(e))
            return

        if self.previous_show_module_path != self.show_module_path:
            # in case switch from tree to flat view
            self.tree_modules_manager.ClearItems()
            self.previous_show_module_path = self.show_module_path

        self.tree_modules_manager.SaveState()

        # load modules from local folder
        for module_path in self.modules:
            library_path = os.path.dirname(module_path)
            if self.show_module_path == True:
                pathobj = self.tree_modules_manager.FindPath(library_path)
                if self.modules_filter.FilterPath(library_path) == False:
                    if self.tree_modules_manager.DropStateObject(
                            pathobj) == False:
                        self.tree_modules_manager.AppendPath(library_path)

            module = self.modules[module_path]
            parent = library_path

            if self.show_both_changes == False and self.show_conflict_changes == False and self.show_incoming_changes == False and self.show_outgoing_changes == False:
                show = True
            else:
                show = False
            if self.show_both_changes == True and module.state.rfind(
                    'outgo_') != -1:
                show = True
            if self.show_both_changes == True and module.state.rfind(
                    'income_') != -1:
                show = True
            if self.show_conflict_changes == True and module.state.rfind(
                    'conflict_') != -1:
                show = True
            if self.show_incoming_changes == True and module.state.rfind(
                    'income_') != -1:
                show = True
            if self.show_outgoing_changes == True and module.state.rfind(
                    'outgo_') != -1:
                show = True

            libraryobj = self.tree_modules_manager.FindModule(parent, module)
            if show == True:
                if self.modules_filter.FilterModule(module) == False:
                    if self.tree_modules_manager.DropStateObject(
                            libraryobj) == False:
                        if self.show_module_path == True:
                            self.tree_modules_manager.AppendModule(parent,
                                                                   module,
                                                                   flat=False)
                        else:
                            self.tree_modules_manager.AppendModule(parent,
                                                                   module,
                                                                   flat=True)

        self.tree_modules_manager.PurgeState()