mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix pathing issue, hoist env check and flip args to correct malformed app path
This commit is contained in:
parent
a00f418fcf
commit
ae41ef1ef9
40
main.py
40
main.py
@ -39,6 +39,20 @@ if not (sys.version_info.major == 3 and sys.version_info.minor >= 9):
|
|||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
Console.info("Crafty stopped. Exiting...")
|
Console.info("Crafty stopped. Exiting...")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Determine the environment we're running in and set path accordingly
|
||||||
|
if getattr(sys, "frozen", False):
|
||||||
|
app_path = os.path.dirname(sys.executable)
|
||||||
|
RUN_MODE = "Frozen/executable"
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
app_full_path = os.path.realpath(__file__)
|
||||||
|
app_path = os.path.dirname(app_full_path)
|
||||||
|
RUN_MODE = "Non-interactive (e.g. 'python main.py')"
|
||||||
|
except NameError:
|
||||||
|
app_path = os.getcwd()
|
||||||
|
RUN_MODE = "Interactive"
|
||||||
|
|
||||||
# pylint: disable=wrong-import-position
|
# pylint: disable=wrong-import-position
|
||||||
try:
|
try:
|
||||||
from app.classes.models.base_model import database_proxy
|
from app.classes.models.base_model import database_proxy
|
||||||
@ -72,12 +86,12 @@ def do_intro():
|
|||||||
|
|
||||||
|
|
||||||
def setup_logging(debug=True):
|
def setup_logging(debug=True):
|
||||||
logging_config_file = os.path.join(os.path.curdir, "app", "config", "logging.json")
|
logging_config_file = os.path.join(app_path, "app", "config", "logging.json")
|
||||||
if not helper.check_file_exists(
|
if not helper.check_file_exists(
|
||||||
os.path.join(os.path.curdir, "logs", "auth_tracker.log")
|
os.path.join(app_path, "logs", "auth_tracker.log")
|
||||||
):
|
):
|
||||||
open(
|
open(
|
||||||
os.path.join(os.path.curdir, "logs", "auth_tracker.log"),
|
os.path.join(app_path, "logs", "auth_tracker.log"),
|
||||||
"a",
|
"a",
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
).close()
|
).close()
|
||||||
@ -152,18 +166,6 @@ if __name__ == "__main__":
|
|||||||
installer = DatabaseBuilder(database, helper, user_helper, management_helper)
|
installer = DatabaseBuilder(database, helper, user_helper, management_helper)
|
||||||
FRESH_INSTALL = installer.is_fresh_install()
|
FRESH_INSTALL = installer.is_fresh_install()
|
||||||
|
|
||||||
if getattr(sys, "frozen", False):
|
|
||||||
app_path = os.path.dirname(sys.executable)
|
|
||||||
RUN_MODE = "Frozen/executable"
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
app_full_path = os.path.realpath(__file__)
|
|
||||||
app_path = os.path.dirname(app_full_path)
|
|
||||||
RUN_MODE = "Non-interactive (e.g. 'python main.py')"
|
|
||||||
except NameError:
|
|
||||||
app_path = os.getcwd()
|
|
||||||
RUN_MODE = "Interactive"
|
|
||||||
|
|
||||||
if FRESH_INSTALL:
|
if FRESH_INSTALL:
|
||||||
Console.debug("Fresh install detected")
|
Console.debug("Fresh install detected")
|
||||||
Console.warning(
|
Console.warning(
|
||||||
@ -271,8 +273,10 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
helper.servers_dir = master_server_dir
|
helper.servers_dir = master_server_dir
|
||||||
|
|
||||||
Console.debug(f"Execution Mode: {running_mode}")
|
logger.info(f"Execution Mode: {running_mode}")
|
||||||
Console.debug(f"Application path : '{application_path}'")
|
logger.info(f"Application path: '{application_path}'")
|
||||||
|
Console.info(f"Execution Mode: {running_mode}")
|
||||||
|
Console.info(f"Application path: '{application_path}'")
|
||||||
|
|
||||||
controller.clear_support_status()
|
controller.clear_support_status()
|
||||||
|
|
||||||
@ -283,7 +287,7 @@ if __name__ == "__main__":
|
|||||||
controller_setup_thread = Thread(
|
controller_setup_thread = Thread(
|
||||||
target=controller_setup,
|
target=controller_setup,
|
||||||
name="controller_setup",
|
name="controller_setup",
|
||||||
args=[RUN_MODE, app_path],
|
args=[app_path, RUN_MODE],
|
||||||
)
|
)
|
||||||
|
|
||||||
def setup_starter():
|
def setup_starter():
|
||||||
|
Loading…
Reference in New Issue
Block a user