"""
This module is responsible for finding the correct executables for the different subprocesses. This is primarily
important for Windows, because the Console and GUI applications use separate and exclusive bases.
"""
import os
import sys


if sys.platform.startswith("win"):
    _ex_dir = os.path.dirname(sys.executable)
    EXEC_CONSOLE = os.path.join(_ex_dir, "clarabot-nano.exe")
    if not os.path.isfile(EXEC_CONSOLE):
        EXEC_CONSOLE = os.path.join(_ex_dir, "python.exe")
    if not os.path.isfile(EXEC_CONSOLE):
        raise Exception(f"No valid console executable found in {_ex_dir}")
    EXEC_GUI = os.path.join(_ex_dir, "clarabot-nanow.exe")
    if not os.path.isfile(EXEC_GUI):
        EXEC_GUI = os.path.join(_ex_dir, "pythonw.exe")
    if not os.path.isfile(EXEC_GUI):
        raise Exception(f"No valid gui executable found in {_ex_dir}")
else:
    EXEC_CONSOLE = EXEC_GUI = sys.executable
