From 7d79b8a3ec20f87c6933545f2f73b5bf814141c5 Mon Sep 17 00:00:00 2001 From: DazedAnon Date: Tue, 19 May 2026 21:15:16 -0500 Subject: [PATCH] Less vague env --- gui/translation_tab.py | 19 +++++++++---------- modules/main.py | 36 ++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/gui/translation_tab.py b/gui/translation_tab.py index f91761a..1235101 100644 --- a/gui/translation_tab.py +++ b/gui/translation_tab.py @@ -282,16 +282,15 @@ class TranslationWorker(QThread): # Check for required environment variables required_envs = ["api", "key", "model", "language", "timeout", "fileThreads", "threads", "width", "listWidth"] - env_missing = False - - for env in required_envs: - if os.getenv(env) is None or str(os.getenv(env))[:1] == "<": - self.emit_log(f"❌ Environment variable {env} is not set!") - env_missing = True - - if env_missing: - self.emit_log("❌ Some required environment variables are not set. Check your .env file.") - self.finished_signal.emit(False, "Environment variables missing") + missing_envs = [ + env for env in required_envs + if os.getenv(env) is None or str(os.getenv(env))[:1] == "<" + ] + if missing_envs: + names = ", ".join(missing_envs) + self.emit_log(f"❌ Missing required environment variable(s): {names}") + self.emit_log(" Check your .env file (see .env.example).") + self.finished_signal.emit(False, f"Missing env: {names}") return # Get files to process diff --git a/modules/main.py b/modules/main.py index 4072848..e2e07b4 100644 --- a/modules/main.py +++ b/modules/main.py @@ -10,27 +10,27 @@ from dotenv import load_dotenv # This needs to be before the module imports as some of them currently try to read and use some of these values # upon import, in which case if they are unset the script will crash before we can output these messages. -envMissing = False load_dotenv() -for env in [ - "api", - "key", - "model", - "language", - "timeout", - "fileThreads", - "threads", - "width", - "listWidth", -]: - if os.getenv(env) is None or str(os.getenv(env))[:1] == "<": - tqdm.write(Fore.RED + f"Environment variable {env} is not set!") - envMissing = True -if envMissing: +_missing_envs = [ + env for env in [ + "api", + "key", + "model", + "language", + "timeout", + "fileThreads", + "threads", + "width", + "listWidth", + ] + if os.getenv(env) is None or str(os.getenv(env))[:1] == "<" +] +if _missing_envs: + names = ", ".join(_missing_envs) tqdm.write( Fore.RED - + "Some of the required environment values may not be set correctly. You can set \ -these values using an .env file, for an example see .env.example" + + f"Missing required environment variable(s): {names}. " + + "Set them in a .env file (see .env.example)." ) from modules.rpgmakermvmz import handleMVMZ, setSpeakerParseMode as setSpeakerParseMVMZ, finalizeSpeakerParse as finalizeSpeakerParseMVMZ