Less vague env
This commit is contained in:
parent
74f07e7017
commit
7d79b8a3ec
2 changed files with 27 additions and 28 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue