From 7cee100c39c7a68bed4cab12ec52f48ef75a3747 Mon Sep 17 00:00:00 2001 From: Benjamin Auquite Date: Fri, 29 Mar 2024 01:26:33 -0500 Subject: [PATCH] remove the test environment --- .../src/toolset/gui/dialogs/select_update.py | 58 ++----------------- 1 file changed, 6 insertions(+), 52 deletions(-) diff --git a/Tools/HolocronToolset/src/toolset/gui/dialogs/select_update.py b/Tools/HolocronToolset/src/toolset/gui/dialogs/select_update.py index 761f4989b..7d3c656ad 100644 --- a/Tools/HolocronToolset/src/toolset/gui/dialogs/select_update.py +++ b/Tools/HolocronToolset/src/toolset/gui/dialogs/select_update.py @@ -1,70 +1,30 @@ from __future__ import annotations import gc -import os -import pathlib import platform import sys from multiprocessing import Process, Queue -from typing import Any +from typing import TYPE_CHECKING, Any import markdown import requests from PyQt5.QtCore import QThread, Qt from PyQt5.QtGui import QFont -from PyQt5.QtWidgets import QApplication, QCheckBox, QComboBox, QDialog, QFormLayout, QHBoxLayout, QLabel, QMessageBox, QPushButton, QTextEdit, QVBoxLayout - - -def fix_sys_and_cwd_path(): - """Fixes sys.path and current working directory for PyKotor. - - This function will determine whether they have the source files downloaded for pykotor in the expected directory. If they do, we - insert the source path to pykotor to the beginning of sys.path so it'll have priority over pip's pykotor package if that is installed. - If the toolset dir exists, change directory to that of the toolset. Allows users to do things like `python -m toolset` - This function should never be used in frozen code. - This function also ensures a user can run toolset/__main__.py directly. - - Processing Logic: - ---------------- - - Checks if PyKotor package exists in parent directory of calling file. - - If exists, removes parent directory from sys.path and adds to front. - - Also checks for toolset package and changes cwd to that directory if exists. - - This ensures packages and scripts can be located correctly on import. - """ - - def update_sys_path(path: pathlib.Path): - working_dir = str(path) - if working_dir not in sys.path: - sys.path.append(working_dir) - - file_absolute_path = pathlib.Path(__file__).resolve() - - pykotor_path = file_absolute_path.parents[7] / "Libraries" / "PyKotor" / "src" / "pykotor" - if pykotor_path.exists(): - update_sys_path(pykotor_path.parent) - pykotor_gl_path = file_absolute_path.parents[7] / "Libraries" / "PyKotorGL" / "src" / "pykotor" - if pykotor_gl_path.exists(): - update_sys_path(pykotor_gl_path.parent) - utility_path = file_absolute_path.parents[7] / "Libraries" / "Utility" / "src" - if utility_path.exists(): - update_sys_path(utility_path) - toolset_path = file_absolute_path.parents[3] / "toolset" - if toolset_path.exists(): - update_sys_path(toolset_path.parent) - os.chdir(toolset_path) - -fix_sys_and_cwd_path() +from PyQt5.QtWidgets import QCheckBox, QComboBox, QDialog, QFormLayout, QHBoxLayout, QLabel, QMessageBox, QPushButton, QTextEdit, QVBoxLayout from toolset.config import LOCAL_PROGRAM_INFO, remoteVersionNewer, toolset_tag_to_version, version_to_toolset_tag from toolset.gui.dialogs.asyncloader import ProgressDialog from utility.logger_util import get_root_logger from utility.misc import ProcessorArchitecture from utility.system.os_helper import kill_child_processes -from utility.updater.github import Asset, GithubRelease +from utility.updater.github import GithubRelease from utility.updater.update import AppUpdate +if TYPE_CHECKING: + from utility.updater.github import Asset + def convert_markdown_to_html(md_text: str) -> str: """Convert Markdown text to HTML.""" @@ -327,9 +287,3 @@ def expected_archive_filenames() -> list[str]: get_root_logger().exception("Error occurred while downloading/installing the toolset.") finally: exitapp(kill_self_here=True) - -if __name__ == "__main__": - app = QApplication([]) - dialog = UpdateDialog() - dialog.show() - app.exec_()