preparation for pyinstaller
This commit is contained in:
@@ -4,7 +4,7 @@ import traceback
|
|||||||
|
|
||||||
def exception_handler(typ_exc, value, trbk):
|
def exception_handler(typ_exc, value, trbk):
|
||||||
"""Testium Exception handling"""
|
"""Testium Exception handling"""
|
||||||
print("An unmanaged exception occured", exc_info=(typ_exc, value, trbk))
|
print("An unmanaged exception occured")
|
||||||
print(f"Critical failure : '{value}'.")
|
print(f"Critical failure : '{value}'.")
|
||||||
tb = traceback.format_exception(typ_exc, value, trbk)
|
tb = traceback.format_exception(typ_exc, value, trbk)
|
||||||
print("".join(tb))
|
print("".join(tb))
|
||||||
|
|||||||
@@ -1,16 +1,9 @@
|
|||||||
import os, sys
|
import os, sys
|
||||||
import logging
|
|
||||||
import traceback
|
import traceback
|
||||||
|
import multiprocessing
|
||||||
logging.basicConfig(
|
|
||||||
level=logging.ERROR,
|
|
||||||
filename=os.path.join(os.path.normpath(os.getcwd()), "crash.txt"),
|
|
||||||
format="%(asctime)s - %(levelname)s - %(message)s"
|
|
||||||
)
|
|
||||||
|
|
||||||
def exception_handler(typ_exc, value, trbk):
|
def exception_handler(typ_exc, value, trbk):
|
||||||
"""Testium Exception handling"""
|
"""Testium Exception handling"""
|
||||||
logging.error("An unmanaged exception occured", exc_info=(typ_exc, value, trbk))
|
|
||||||
print(f"Critical failure : '{value}'.")
|
print(f"Critical failure : '{value}'.")
|
||||||
tb = traceback.format_exception(typ_exc, value, trbk)
|
tb = traceback.format_exception(typ_exc, value, trbk)
|
||||||
print("".join(tb[-4:]))
|
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
|
from testium import main
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
multiprocessing.freeze_support()
|
||||||
main()
|
main()
|
||||||
@@ -5,7 +5,7 @@ import subprocess
|
|||||||
import socket
|
import socket
|
||||||
|
|
||||||
import libs.testium as tm
|
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.tum_except import ETUMRuntimeError
|
||||||
from interpreter.utils.jrpc import JsonRpcClient
|
from interpreter.utils.jrpc import JsonRpcClient
|
||||||
from interpreter.utils.paths import sys_app_path_lin, sys_app_path_win
|
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.")
|
tm.print_debug(f"'{sys_lua_bin}' not a lua 5.1 min.")
|
||||||
sys_lua_bin = ""
|
sys_lua_bin = ""
|
||||||
|
|
||||||
|
tm.print_debug(f"lua bin is: '{sys_lua_bin}'.")
|
||||||
tm.setgd("_sys_lua_bin", sys_lua_bin)
|
tm.setgd("_sys_lua_bin", sys_lua_bin)
|
||||||
return sys_lua_bin
|
return sys_lua_bin
|
||||||
|
|
||||||
@@ -145,7 +146,7 @@ class LuaProcessBase:
|
|||||||
raise ETUMRuntimeError("The function subprocess has already been started.")
|
raise ETUMRuntimeError("The function subprocess has already been started.")
|
||||||
|
|
||||||
func_proc_path = os.path.realpath(
|
func_proc_path = os.path.realpath(
|
||||||
os.path.join(testium_path(), "..", "lua_func")
|
os.path.join(subproc_path(), "lua_func")
|
||||||
)
|
)
|
||||||
|
|
||||||
# POpen config
|
# POpen config
|
||||||
@@ -159,7 +160,7 @@ class LuaProcessBase:
|
|||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
if not isinstance(lua_env, dict):
|
if not isinstance(lua_env, dict):
|
||||||
raise ETUMRuntimeError(f"The 'lua_env' global value should be a dictionary. But it is '{lua_env}'.")
|
raise ETUMRuntimeError(f"The 'lua_env' global value should be a dictionary. But it is '{lua_env}'.")
|
||||||
|
|
||||||
for k, v in CUST_ENV.items():
|
for k, v in CUST_ENV.items():
|
||||||
e = lua_env.get(k, "")
|
e = lua_env.get(k, "")
|
||||||
if e != "":
|
if e != "":
|
||||||
|
|||||||
@@ -9,9 +9,23 @@ import libs.testium as tm
|
|||||||
|
|
||||||
|
|
||||||
def testium_path():
|
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))
|
tp = inspect.getfile(inspect.getmodule(testium))
|
||||||
return str(Path(tp).parent.resolve())
|
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=""):
|
def prepare_file_to_save(file_name, file_ext=""):
|
||||||
iname = file_name
|
iname = file_name
|
||||||
|
|||||||
@@ -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.paths import sys_app_path_lin, sys_app_path_win
|
||||||
from interpreter.utils.tum_except import ETUMRuntimeError
|
from interpreter.utils.tum_except import ETUMRuntimeError
|
||||||
from interpreter.utils.jrpc import JsonRpcClient
|
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):
|
def _python_version(path: str):
|
||||||
@@ -69,8 +69,9 @@ def _sys_python_bin():
|
|||||||
continue
|
continue
|
||||||
if _is_python3(sys_python_bin):
|
if _is_python3(sys_python_bin):
|
||||||
break
|
break
|
||||||
sys_python_bin = ""
|
sys_python_bin = ""
|
||||||
|
|
||||||
|
tm.print_debug(f"python bin is: '{sys_python_bin}'.")
|
||||||
return sys_python_bin
|
return sys_python_bin
|
||||||
|
|
||||||
|
|
||||||
@@ -123,7 +124,7 @@ class PyProcessBase:
|
|||||||
py_env = tm.gd("python_env", {})
|
py_env = tm.gd("python_env", {})
|
||||||
if not isinstance(py_env, dict):
|
if not isinstance(py_env, dict):
|
||||||
raise ETUMRuntimeError(f"The 'py_env' global value should be a dictionary. But it is '{py_env}'.")
|
raise ETUMRuntimeError(f"The 'py_env' global value should be a dictionary. But it is '{py_env}'.")
|
||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
for k, v in self.CUST_ENV.items():
|
for k, v in self.CUST_ENV.items():
|
||||||
e = py_env.get(k, "")
|
e = py_env.get(k, "")
|
||||||
@@ -141,8 +142,9 @@ class PyProcessBase:
|
|||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
# Add the path of the subprocess (root sources of testium)
|
# Add the path of the subprocess (root sources of testium)
|
||||||
func_proc_path = os.path.realpath(os.path.join(testium_path(), ".."))
|
tstium_path = os.path.realpath(testium_path())
|
||||||
env["PYTHONPATH"] = func_proc_path + os.pathsep + self._ppath + os.pathsep + env.get("PYTHONPATH", "")
|
func_proc_path = os.path.realpath(subproc_path())
|
||||||
|
env["PYTHONPATH"] = tstium_path + os.pathsep + self._ppath + os.pathsep + env.get("PYTHONPATH", "")
|
||||||
|
|
||||||
params = [
|
params = [
|
||||||
self._pbin,
|
self._pbin,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from PySide6.QtWidgets import QDialog
|
|||||||
from PySide6.QtGui import QSyntaxHighlighter, QTextCharFormat, QColor, QFont, QDesktopServices
|
from PySide6.QtGui import QSyntaxHighlighter, QTextCharFormat, QColor, QFont, QDesktopServices
|
||||||
from PySide6.QtCore import Qt, QUrl
|
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):
|
class YamlHighlighter(QSyntaxHighlighter):
|
||||||
|
|||||||
Reference in New Issue
Block a user