Skip to content

Commit

Permalink
remove the test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
th3w1zard1 committed Mar 29, 2024
1 parent b6d7e6c commit 7cee100
Showing 1 changed file with 6 additions and 52 deletions.
58 changes: 6 additions & 52 deletions Tools/HolocronToolset/src/toolset/gui/dialogs/select_update.py
Original file line number Diff line number Diff line change
@@ -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."""
Expand Down Expand Up @@ -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_()

0 comments on commit 7cee100

Please sign in to comment.