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 __recover_app(self): if len(self.settings_backup) > 0: settings_data = "" for line in self.settings_backup: settings_data += line write_to_file(self.settings_file, settings_data) if len(self.urls_backup) > 0: urls_data = "" for line in self.urls_backup: urls_data += line write_to_file(self.urls_file, urls_data)
def __edit_settings_py(self): data = readlines_from_file(self.settings_file) self.settings_backup = data index = -1 for i in range(0, len(data)): if "INSTALLED_APPS" in data[i]: j = i for i in range(i, len(data)): if "katana.wui.core" in data[i]: index = i break break white_space = data[index].split("'") self.pkg_in_settings = white_space[ 0] + "'" + self.pkg_in_settings + "',\n" sf_data = data[:index] sf_data.append(self.pkg_in_settings) sf_data.extend(data[index:]) settings_data = "" for line in sf_data: settings_data += line output = write_to_file(self.settings_file, settings_data) return output
def __edit_urls_py(self): checker = "RedirectView.as_view(url='/katana/')" data = read_json_data(self.wf_config_file) if data["app"]["url"].startswith("/"): app_url = data["app"]["url"][1:] else: app_url = data["app"]["url"] self.urls_inclusions.append("url(r'^" + app_url + "', include('" + data["app"]["include"] + "')),") data = readlines_from_file(self.urls_file) self.urls_backup = data index = -1 for i in range(0, len(data)): if checker in data[i]: index = i + 1 break white_space = data[index].split("url") for i in range(0, len(self.urls_inclusions)): self.urls_inclusions[ i] = white_space[0] + self.urls_inclusions[i] + "\n" u_data = data[:index] u_data.extend(self.urls_inclusions) u_data.extend(data[index:]) urls_data = "" for line in u_data: urls_data += line output = write_to_file(self.urls_file, urls_data) return output
def __remove_app_from_urls(self): data = readlines_from_file(self.urls_file) urls_data = "" for url in self.include_urls: urls_data = "" for line in data: if url not in line: urls_data += line data = urls_data output = write_to_file(self.urls_file, urls_data) return output
def __remove_app_from_settings(self): data = readlines_from_file(self.settings_file) sf_data = [] for line in data: if line.strip() != "'{0}',".format(self.pkg_in_settings): sf_data.append(line) settings_data = "" for line in sf_data: settings_data += line output = write_to_file(self.settings_file, settings_data) return output