Exemplo n.º 1
0
    def update_list(self):
        self.model.removeRows(0, self.model.rowCount())
        current_repo = self.repo_box.currentText()
        if current_repo == "":
            return
        if current_repo not in self.repo_dictionary.keys():
            self.repo_dictionary[current_repo] = sorted(
                Publish._get_packages(self.data_manager.get_client(), "repos",
                                      current_repo))

        if self.repo_dictionary[current_repo]:
            for package in self.repo_dictionary[current_repo]:
                item = QStandardItem(package)
                item.setCheckable(True)
                item.setCheckState(Qt.Unchecked)
                self.model.appendRow(item)
            self.package_label.setModel(self.model)
Exemplo n.º 2
0
    def get_package_from_publish_component(self, publish, component):
        snapshot = self.publish_dict[publish].components[component][0]

        return sorted(Publish._get_packages(self.client, "snapshots",
                                            snapshot))
Exemplo n.º 3
0
    def run(self):
        publish_dict = {}
        repo_dict = {}

        try:
            publishes = self.client.do_get('/publish')
            repos = self.client.do_get('/repos')
        except Exception as e:
            self.log.emit(e, "error")
            self.terminate()

        i = 0
        nb_max = len(publishes) + len(repos)

        for repo in repos:
            i += 1
            self.log.emit("Loading repository {0}".format(repo["Name"]),
                          "info")
            self.progress.emit(i / nb_max * 100)
            repo_dict[repo["Name"]] = sorted(
                Publish._get_packages(self.data_manager.get_client(), "repos",
                                      repo["Name"]))

        for publish in publishes:
            i += 1
            name = "{}{}{}".format(
                publish['Storage'] + ":" if publish['Storage'] else "",
                publish['Prefix'] + "/" if publish['Prefix'] else "",
                publish['Distribution'])

            # Only publishes made of snapshots are loaded, others are managed in the repository tab
            if publish['SourceKind'] != 'snapshot':
                continue

            self.progress.emit(i / nb_max * 100)
            self.log.emit("Loading publish {0}".format(name), "info")

            tmp = Publish(self.client,
                          name,
                          load=True,
                          storage=publish.get('Storage', "local"))
            publish_dict[name] = tmp

            for snapshot in tmp.publish_snapshots:
                try:
                    if self.cancelled:
                        self.terminate()
                    self.log.emit(
                        "Loading snapshot {0} of publish {1}".format(
                            snapshot["Name"], name), "debug")
                    Publish._get_packages(self.client, "snapshots",
                                          snapshot["Name"])
                except Exception as e:
                    self.log.emit(
                        "Failed to fetch snapshot {0}: {1}".format(
                            snapshot["Name"], e), "error")
            if self.cancelled:
                self.terminate()

        self.log.emit("Successfully loaded publishes", "success")
        self.data_manager.publish_dict = publish_dict
        self.data_manager.repo_dict = repo_dict