def __revert_installation(self): output = True if len(self.urls_backup) > 0: urls_data = "" for line in self.urls_backup: urls_data += line output = write_to_file(self.urls_file, urls_data) if len(self.settings_backup) > 0: settings_data = "" for line in self.settings_backup: settings_data += line output = write_to_file(self.settings_file, settings_data) for app_path in self.delete_app_dir: output = delete_dir(app_path) if output: for plugin_path in self.delete_plugins_dir: if output: output = delete_dir(plugin_path) return output
def _clone_repository(self): repo_directory = os.path.join(self.base_directory, self.repo_name) if os.path.isdir(repo_directory): delete_dir(repo_directory) current_directory = os.getcwd() os.chdir(self.base_directory) os.system("git clone {0}".format(self.url)) os.chdir(current_directory) return os.path.join(self.base_directory, self.repo_name)
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(), "katana.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 })
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 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(), "katana.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
def __delete_cache_dir(self): output = delete_dir(get_parent_directory(self.cache_dir)) return output
def __delete_app_dirs(self): output = delete_dir(self.app_path) for plugin in self.related_plugins: output = output and delete_dir(plugin) return output