Exemple #1
0
def check_tools_repo_availability(request):
    available = True
    url = request.POST.get('url')
    repo_name = get_repository_name(url)
    if not check_url_is_a_valid_repo(url):
        available = False
    return JsonResponse({"available": available, "repo_name": repo_name})
Exemple #2
0
    def verify_tools_data(self):
        if "tools" not in self.data["data"]:
            self.data["data"]["tools"] = copy.deepcopy(
                self.ref_data["data"]["tools"])
        else:
            for key, value in list(self.ref_data["data"]["tools"].items()):
                if key not in self.data["data"]["tools"]:
                    self.data["data"]["tools"][key] = self.ref_data["data"][
                        "tools"][key]

            url = self.data["data"]["tools"]["@url"]
            if url != "":
                self.data["data"]["tools"]["name"] = get_repository_name(
                    url=url)
                self.data["data"]["tools"][
                    "available"] = check_url_is_a_valid_repo(url=url)
            else:
                self.data["data"]["tools"]["available"] = False
Exemple #3
0
def check_repo_availability(request):
    available = True
    url = request.POST.get('url')
    repo_name = get_repository_name(url)
    drivers = []
    if not check_url_is_a_valid_repo(url):
        available = False
    else:
        temp_directory = os.path.join(nav_obj.get_katana_dir(), "wapps",
                                      "assembler", ".data")
        kw_repo_obj = KwRepositoryDetails(url, temp_directory)
        drivers = kw_repo_obj.get_pd_names()
        if os.path.isdir(kw_repo_obj.repo_directory):
            delete_dir(kw_repo_obj.repo_directory)
    return JsonResponse({
        "available": available,
        "repo_name": repo_name,
        "drivers": drivers
    })
Exemple #4
0
    def verify_warriorspace_data(self):
        flag = True
        if "warriorspace" not in self.data["data"]:
            flag = False
            self.data["data"]["warriorspace"] = copy.deepcopy(
                self.ref_data["data"]["warriorspace"])

        if "repository" not in self.data["data"]["warriorspace"]:
            flag = False
            self.data["data"]["warriorspace"]["repository"] = copy.copy(
                self.ref_data["data"]["warriorspace"]["repository"])

        if not isinstance(self.data["data"]["warriorspace"]["repository"],
                          list):
            self.data["data"]["warriorspace"]["repository"] = [
                self.data["data"]["warriorspace"]["repository"]
            ]

        if flag:
            for i in range(
                    0, len(self.data["data"]["warriorspace"]["repository"])):
                for key, value in list(self.ref_data["data"]["warriorspace"]
                                       ["repository"].items()):
                    if key not in self.data["data"]["warriorspace"][
                            "repository"][i]:
                        self.data["data"]["warriorspace"]["repository"][i][
                            key] = self.ref_data["data"]["warriorspace"][
                                "repository"][key]

                url = self.data["data"]["warriorspace"]["repository"][i][
                    "@url"]
                if url != "":
                    self.data["data"]["warriorspace"]["repository"][i][
                        "name"] = get_repository_name(url=url)
                    self.data["data"]["warriorspace"]["repository"][i][
                        "available"] = check_url_is_a_valid_repo(url=url)
                else:
                    self.data["data"]["warriorspace"]["repository"][i][
                        "available"] = False
Exemple #5
0
    def verify_drivers_json(self):
        flag = True
        if "drivers" not in self.data["data"]:
            self.data["data"]["drivers"] = copy.deepcopy(
                self.ref_data["data"]["drivers"])
            flag = False

        if "repository" not in self.data["data"]["drivers"]:
            self.data["data"]["drivers"]["repository"] = copy.deepcopy(
                self.ref_data["data"]["drivers"]["repository"])
            flag = False

        if not isinstance(self.data["data"]["drivers"]["repository"], list):
            self.data["data"]["drivers"]["repository"] = [
                self.data["data"]["drivers"]["repository"]
            ]

        if flag:
            for i in range(0, len(self.data["data"]["drivers"]["repository"])):
                for key, value in list(self.ref_data["data"]["drivers"]
                                       ["repository"].items()):
                    if key not in self.data["data"]["drivers"]["repository"][
                            i]:
                        if key != "driver":
                            self.data["data"]["drivers"]["repository"][i][
                                key] = self.ref_data["data"]["drivers"][
                                    "repository"]["key"]
                        else:
                            self.data["data"]["drivers"]["repository"][i][
                                key] = copy.deepcopy(
                                    self.ref_data["data"]["drivers"]
                                    ["repository"][key])

                            if not isinstance(
                                    self.data["data"]["drivers"]["repository"]
                                [i][key], list):
                                self.data["data"]["drivers"]["repository"][i][
                                    key] = [
                                        self.data["data"]["drivers"]
                                        ["repository"][i][key]
                                    ]

                url = self.data["data"]["drivers"]["repository"][i]["@url"]
                if url != "":
                    self.data["data"]["drivers"]["repository"][i][
                        "name"] = get_repository_name(url=url)
                    available = check_url_is_a_valid_repo(url=url)
                    self.data["data"]["drivers"]["repository"][i][
                        "available"] = available
                    if available:
                        drivers_data = []
                        drivers_index = set()
                        temp_directory = os.path.join(
                            self.nav_obj.get_katana_dir(), "wapps",
                            "assembler", ".data")
                        kw_repo_obj = KwRepositoryDetails(url, temp_directory)
                        drivers = set(kw_repo_obj.get_pd_names())

                        if not isinstance(
                                self.data["data"]["drivers"]["repository"][i]
                            ["driver"], list):
                            self.data["data"]["drivers"]["repository"][i][
                                "driver"] = [
                                    self.data["data"]["drivers"]["repository"]
                                    [i]["driver"]
                                ]

                        for j in range(
                                0,
                                len(self.data["data"]["drivers"]["repository"]
                                    [i]["driver"])):
                            if "@name" not in self.data["data"]["drivers"][
                                    "repository"][i]["driver"][j]:
                                self.data["data"]["drivers"]["repository"][i][
                                    "driver"][j]["@name"] = self.ref_data[
                                        "data"]["drivers"]["repository"][
                                            "driver"]["@name"]
                            else:
                                if self.data["data"]["drivers"]["repository"][
                                        i]["driver"][j]["@name"] in drivers:
                                    drivers.remove(self.data["data"]["drivers"]
                                                   ["repository"][i]["driver"]
                                                   [j]["@name"])
                                else:
                                    drivers_index.add(j)
                            if "@clone" not in self.data["data"]["drivers"][
                                    "repository"][i]["driver"][j]:
                                self.data["data"]["drivers"]["repository"][i][
                                    "driver"][j]["@clone"] = self.ref_data[
                                        "data"]["drivers"]["repository"][
                                            "driver"]["@clone"]

                        for j in range(
                                0,
                                len(self.data["data"]["drivers"]["repository"]
                                    [i]["driver"])):
                            if j not in drivers_index:
                                drivers_data.append(
                                    copy.deepcopy(
                                        self.data["data"]["drivers"]
                                        ["repository"][i]["driver"][j]))
                        self.data["data"]["drivers"]["repository"][i][
                            "driver"] = copy.deepcopy(drivers_data)

                        for driver_name in drivers:
                            self.data["data"]["drivers"]["repository"][i][
                                "driver"].append({
                                    "@name": driver_name,
                                    "@clone": "no"
                                })

                        if os.path.isdir(kw_repo_obj.repo_directory):
                            delete_dir(kw_repo_obj.repo_directory)
                else:
                    self.data["data"]["drivers"]["repository"][i][
                        "available"] = False