Centralize IS_FROZEN check

This commit is contained in:
David Sangrey committed 2026-01-27 23:30:49 -05:00
1 parent 90701d9edb
commit 0d689a3c7d
5 files changed
+17 -17

No files matched your search

+2 -3
View File
@@ -20,7 +20,6 @@ import json
import numbers
import os
import random
import sys
import threading
import time
import tkinter as tk
@@ -39,7 +38,7 @@ from urllib3.util.retry import Retry
import config as conf_module
import killswitch
import protocol
from config import config, user_agent
from config import config, user_agent, IS_FROZEN
from edmc_data import companion_category_map as category_map
from EDMCLogging import get_main_logger
from monitor import monitor
@@ -668,7 +667,7 @@ class Session:
self.state = Session.STATE_INIT # Will try to authorize again on next login or query
self.auth = None
raise # Bad thing happened
if getattr(sys, 'frozen', False):
if IS_FROZEN:
tk.messagebox.showinfo(title="Authentication Successful", # type: ignore
message="Authentication with cAPI Successful.\n"
"You may now close the Frontier login tab if it is still open.")
+4 -2
View File
@@ -31,6 +31,7 @@ __all__ = [
"config",
"get_update_feed",
"config_logger",
"IS_FROZEN",
]
import contextlib
@@ -58,6 +59,7 @@ appcmdname = "EDMC"
_static_appversion = "6.1.2-beta1"
_cached_version: semantic_version.Version | None = None
copyright = "© 2015-2019 Jonathan Harris, 2020-2026 EDCD"
IS_FROZEN = getattr(sys, 'frozen', False)
update_interval = 8 * 60 * 60 # 8 Hours
@@ -89,7 +91,7 @@ def git_shorthash_from_head() -> str | None:
:return: str | None: None if we couldn't determine the short hash.
"""
if getattr(sys, 'frozen', False) or not os.path.exists(".git"):
if IS_FROZEN or not os.path.exists(".git"):
return None
try:
@@ -126,7 +128,7 @@ def appversion() -> semantic_version.Version:
if _cached_version is not None:
return _cached_version
if getattr(sys, "frozen", False):
if IS_FROZEN:
# Running frozen, so we should have a .gitversion file
# Yes, .parent because if frozen we're inside library.zip
with open(
+2 -2
View File
@@ -14,7 +14,7 @@ import uuid
import winreg
import datetime
import tomli_w
from config import config_logger
from config import config_logger, IS_FROZEN
from win32comext.shell import shell
from typing import Any, TYPE_CHECKING
@@ -117,7 +117,7 @@ class WinConfigMinimal:
def win_helper(config: Config) -> Config:
"""Set Environment Specific Variables for Windows Config."""
config_logger.debug("Windows environment detected. Setting platform-specific variables.")
if getattr(sys, "frozen", False):
if IS_FROZEN:
config.respath_path = pathlib.Path(sys.executable).parent
config.internal_plugin_dir_path = config.respath_path / "plugins"
else:
+2 -2
View File
@@ -19,7 +19,7 @@ from os import listdir, sep
from typing import TextIO, cast
from collections.abc import Iterable
import pathlib
from config import config
from config import config, IS_FROZEN
from EDMCLogging import get_main_logger
# Note that this is also done in EDMarketConnector.py, and thus removing this here may not have a desired effect
@@ -212,7 +212,7 @@ class Translations:
def respath(self) -> pathlib.Path:
"""Path to localisation files."""
if getattr(sys, 'frozen', False):
if IS_FROZEN:
return pathlib.Path(sys.executable).parent.joinpath(LOCALISATION_DIR).resolve()
if __file__:
+7 -8
View File
@@ -17,7 +17,7 @@ from collections.abc import Callable
import plugin_browser
import myNotebook as nb # noqa: N813
import plug
from config import appversion_nobuild, config
from config import appversion_nobuild, config, IS_FROZEN
from EDMCLogging import edmclogger, get_main_logger
from hotkey import hotkeymgr
from l10n import translations as tr
@@ -50,16 +50,15 @@ def open_folder(file: Path) -> None:
def help_open_system_profiler(parent) -> None:
"""Open the EDMC System Profiler."""
profiler_path = config.respath_path
if IS_FROZEN:
cmd = [str(Path(config.respath_path) / 'EDMCSystemProfiler.exe')]
else:
cmd = [sys.executable, str(Path(config.respath_path) / "EDMCSystemProfiler.py")]
try:
if getattr(sys, 'frozen', False):
profiler_path /= 'EDMCSystemProfiler.exe'
subprocess.run(profiler_path, check=True)
else:
subprocess.run(['python', "EDMCSystemProfiler.py"], shell=False, check=True)
subprocess.Popen(cmd, shell=False)
except Exception as err:
parent.status["text"] = tr.tl("Error in System Profiler") # LANG: Catch & Record Profiler Errors
logger.exception(err)
logger.exception(f"Failed to launch System Profiler: {err}")
class PrefsVersion: