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
|
# Check for required environment variables
|
||||||
required_envs = ["api", "key", "model", "language", "timeout", "fileThreads", "threads", "width", "listWidth"]
|
required_envs = ["api", "key", "model", "language", "timeout", "fileThreads", "threads", "width", "listWidth"]
|
||||||
env_missing = False
|
missing_envs = [
|
||||||
|
env for env in required_envs
|
||||||
for env in required_envs:
|
if os.getenv(env) is None or str(os.getenv(env))[:1] == "<"
|
||||||
if os.getenv(env) is None or str(os.getenv(env))[:1] == "<":
|
]
|
||||||
self.emit_log(f"❌ Environment variable {env} is not set!")
|
if missing_envs:
|
||||||
env_missing = True
|
names = ", ".join(missing_envs)
|
||||||
|
self.emit_log(f"❌ Missing required environment variable(s): {names}")
|
||||||
if env_missing:
|
self.emit_log(" Check your .env file (see .env.example).")
|
||||||
self.emit_log("❌ Some required environment variables are not set. Check your .env file.")
|
self.finished_signal.emit(False, f"Missing env: {names}")
|
||||||
self.finished_signal.emit(False, "Environment variables missing")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get files to process
|
# 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
|
# 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.
|
# upon import, in which case if they are unset the script will crash before we can output these messages.
|
||||||
envMissing = False
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
for env in [
|
_missing_envs = [
|
||||||
"api",
|
env for env in [
|
||||||
"key",
|
"api",
|
||||||
"model",
|
"key",
|
||||||
"language",
|
"model",
|
||||||
"timeout",
|
"language",
|
||||||
"fileThreads",
|
"timeout",
|
||||||
"threads",
|
"fileThreads",
|
||||||
"width",
|
"threads",
|
||||||
"listWidth",
|
"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!")
|
if os.getenv(env) is None or str(os.getenv(env))[:1] == "<"
|
||||||
envMissing = True
|
]
|
||||||
if envMissing:
|
if _missing_envs:
|
||||||
|
names = ", ".join(_missing_envs)
|
||||||
tqdm.write(
|
tqdm.write(
|
||||||
Fore.RED
|
Fore.RED
|
||||||
+ "Some of the required environment values may not be set correctly. You can set \
|
+ f"Missing required environment variable(s): {names}. "
|
||||||
these values using an .env file, for an example see .env.example"
|
+ "Set them in a .env file (see .env.example)."
|
||||||
)
|
)
|
||||||
|
|
||||||
from modules.rpgmakermvmz import handleMVMZ, setSpeakerParseMode as setSpeakerParseMVMZ, finalizeSpeakerParse as finalizeSpeakerParseMVMZ
|
from modules.rpgmakermvmz import handleMVMZ, setSpeakerParseMode as setSpeakerParseMVMZ, finalizeSpeakerParse as finalizeSpeakerParseMVMZ
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue