diff --git a/src/py_func/__main__.py b/src/py_func/__main__.py index a24f8ee..8ac1782 100644 --- a/src/py_func/__main__.py +++ b/src/py_func/__main__.py @@ -4,7 +4,7 @@ import traceback def exception_handler(typ_exc, value, trbk): """Testium Exception handling""" - print("An unmanaged exception occured", exc_info=(typ_exc, value, trbk)) + print("An unmanaged exception occured") print(f"Critical failure : '{value}'.") tb = traceback.format_exception(typ_exc, value, trbk) print("".join(tb)) diff --git a/src/testium/__main__.py b/src/testium/__main__.py index 1f37e3a..02f623e 100644 --- a/src/testium/__main__.py +++ b/src/testium/__main__.py @@ -1,16 +1,9 @@ import os, sys -import logging import traceback - -logging.basicConfig( - level=logging.ERROR, - filename=os.path.join(os.path.normpath(os.getcwd()), "crash.txt"), - format="%(asctime)s - %(levelname)s - %(message)s" -) +import multiprocessing def exception_handler(typ_exc, value, trbk): """Testium Exception handling""" - logging.error("An unmanaged exception occured", exc_info=(typ_exc, value, trbk)) print(f"Critical failure : '{value}'.") tb = traceback.format_exception(typ_exc, value, trbk) print("".join(tb[-4:])) @@ -22,4 +15,6 @@ sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) from testium import main if __name__ == '__main__': + if getattr(sys, 'frozen', False): + multiprocessing.freeze_support() main() \ No newline at end of file diff --git a/src/testium/interpreter/utils/lua_process.py b/src/testium/interpreter/utils/lua_process.py index b7591f5..d1db704 100644 --- a/src/testium/interpreter/utils/lua_process.py +++ b/src/testium/interpreter/utils/lua_process.py @@ -5,7 +5,7 @@ import subprocess import socket import libs.testium as tm -from interpreter.utils.paths import testium_path +from interpreter.utils.paths import subproc_path from interpreter.utils.tum_except import ETUMRuntimeError from interpreter.utils.jrpc import JsonRpcClient from interpreter.utils.paths import sys_app_path_lin, sys_app_path_win @@ -58,6 +58,7 @@ def _sys_lua_bin(): tm.print_debug(f"'{sys_lua_bin}' not a lua 5.1 min.") sys_lua_bin = "" + tm.print_debug(f"lua bin is: '{sys_lua_bin}'.") tm.setgd("_sys_lua_bin", sys_lua_bin) return sys_lua_bin @@ -145,7 +146,7 @@ class LuaProcessBase: raise ETUMRuntimeError("The function subprocess has already been started.") func_proc_path = os.path.realpath( - os.path.join(testium_path(), "..", "lua_func") + os.path.join(subproc_path(), "lua_func") ) # POpen config @@ -159,7 +160,7 @@ class LuaProcessBase: env = os.environ.copy() if not isinstance(lua_env, dict): raise ETUMRuntimeError(f"The 'lua_env' global value should be a dictionary. But it is '{lua_env}'.") - + for k, v in CUST_ENV.items(): e = lua_env.get(k, "") if e != "": diff --git a/src/testium/interpreter/utils/paths.py b/src/testium/interpreter/utils/paths.py index 2621632..bb4fbcb 100644 --- a/src/testium/interpreter/utils/paths.py +++ b/src/testium/interpreter/utils/paths.py @@ -9,9 +9,23 @@ import libs.testium as tm def testium_path(): + + if getattr(sys, 'frozen', False): + # Exécuté depuis le .exe + print(f"Path: {sys._MEIPASS}") + return sys._MEIPASS + tp = inspect.getfile(inspect.getmodule(testium)) return str(Path(tp).parent.resolve()) +def subproc_path(): + if getattr(sys, 'frozen', False): + # Exécuté depuis le .exe + print(f"Path: {sys._MEIPASS}") + return sys._MEIPASS + + tp = inspect.getfile(inspect.getmodule(testium)) + return str(Path(tp).parent.parent.resolve()) def prepare_file_to_save(file_name, file_ext=""): iname = file_name diff --git a/src/testium/interpreter/utils/py_process.py b/src/testium/interpreter/utils/py_process.py index 7a1c636..1666de8 100644 --- a/src/testium/interpreter/utils/py_process.py +++ b/src/testium/interpreter/utils/py_process.py @@ -7,7 +7,7 @@ import libs.testium as tm from interpreter.utils.paths import sys_app_path_lin, sys_app_path_win from interpreter.utils.tum_except import ETUMRuntimeError from interpreter.utils.jrpc import JsonRpcClient -from interpreter.utils.paths import testium_path +from interpreter.utils.paths import testium_path, subproc_path def _python_version(path: str): @@ -69,8 +69,9 @@ def _sys_python_bin(): continue if _is_python3(sys_python_bin): break - sys_python_bin = "" + sys_python_bin = "" + tm.print_debug(f"python bin is: '{sys_python_bin}'.") return sys_python_bin @@ -123,7 +124,7 @@ class PyProcessBase: py_env = tm.gd("python_env", {}) if not isinstance(py_env, dict): raise ETUMRuntimeError(f"The 'py_env' global value should be a dictionary. But it is '{py_env}'.") - + env = os.environ.copy() for k, v in self.CUST_ENV.items(): e = py_env.get(k, "") @@ -141,8 +142,9 @@ class PyProcessBase: sock.close() # Add the path of the subprocess (root sources of testium) - func_proc_path = os.path.realpath(os.path.join(testium_path(), "..")) - env["PYTHONPATH"] = func_proc_path + os.pathsep + self._ppath + os.pathsep + env.get("PYTHONPATH", "") + tstium_path = os.path.realpath(testium_path()) + func_proc_path = os.path.realpath(subproc_path()) + env["PYTHONPATH"] = tstium_path + os.pathsep + self._ppath + os.pathsep + env.get("PYTHONPATH", "") params = [ self._pbin, diff --git a/src/testium/main_win/f1_win/d_f1_win.py b/src/testium/main_win/f1_win/d_f1_win.py index 1304083..8c3112b 100644 --- a/src/testium/main_win/f1_win/d_f1_win.py +++ b/src/testium/main_win/f1_win/d_f1_win.py @@ -7,7 +7,7 @@ from PySide6.QtWidgets import QDialog from PySide6.QtGui import QSyntaxHighlighter, QTextCharFormat, QColor, QFont, QDesktopServices from PySide6.QtCore import Qt, QUrl -from testium.main_win.f1_win.f1_win_core import Ui_F1Dialog +from main_win.f1_win.f1_win_core import Ui_F1Dialog class YamlHighlighter(QSyntaxHighlighter):