test-pioneer-dev 0.0.38__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. test_pioneer/__init__.py +7 -0
  2. test_pioneer/__main__.py +0 -0
  3. test_pioneer/extend/__init__.py +0 -0
  4. test_pioneer/extend/mail_thunder_extend/__init__.py +0 -0
  5. test_pioneer/extend/mail_thunder_extend/mail_thunder_setting.py +36 -0
  6. test_pioneer/extend/process_executor/__init__.py +0 -0
  7. test_pioneer/extend/process_executor/api_testka/__init__.py +0 -0
  8. test_pioneer/extend/process_executor/api_testka/api_testka_process.py +66 -0
  9. test_pioneer/extend/process_executor/auto_control/__init__.py +0 -0
  10. test_pioneer/extend/process_executor/auto_control/auto_control_process.py +62 -0
  11. test_pioneer/extend/process_executor/file_automation/__init__.py +0 -0
  12. test_pioneer/extend/process_executor/file_automation/file_automation_process.py +66 -0
  13. test_pioneer/extend/process_executor/load_density/__init__.py +0 -0
  14. test_pioneer/extend/process_executor/load_density/load_density_process.py +66 -0
  15. test_pioneer/extend/process_executor/mail_thunder/__init__.py +0 -0
  16. test_pioneer/extend/process_executor/mail_thunder/mail_thunder_process.py +16 -0
  17. test_pioneer/extend/process_executor/process_executor_utils.py +72 -0
  18. test_pioneer/extend/process_executor/task_process_manager.py +164 -0
  19. test_pioneer/extend/process_executor/web_runner/__init__.py +0 -0
  20. test_pioneer/extend/process_executor/web_runner/web_runner_process.py +66 -0
  21. test_pioneer/test_pioneer_editor_ui/__init__.py +0 -0
  22. test_pioneer/test_pioneer_editor_ui/editor_main/__init__.py +0 -0
  23. test_pioneer/test_pioneer_editor_ui/editor_main/main_ui.py +76 -0
  24. test_pioneer/test_pioneer_editor_ui/extend_multi_language/__init__.py +0 -0
  25. test_pioneer/test_pioneer_editor_ui/extend_multi_language/extend_english.py +98 -0
  26. test_pioneer/test_pioneer_editor_ui/extend_multi_language/extend_traditional_chinese.py +98 -0
  27. test_pioneer/test_pioneer_editor_ui/extend_multi_language/update_language_dict.py +8 -0
  28. test_pioneer/test_pioneer_editor_ui/menu/__init__.py +0 -0
  29. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/__init__.py +0 -0
  30. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/api_testka_menu/__init__.py +0 -0
  31. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/api_testka_menu/build_api_testka_menu.py +120 -0
  32. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/auto_control_menu/__init__.py +0 -0
  33. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/auto_control_menu/build_autocontrol_menu.py +147 -0
  34. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/automation_file_menu/__init__.py +0 -0
  35. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/automation_file_menu/build_automation_file_menu.py +122 -0
  36. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/load_density_menu/__init__.py +0 -0
  37. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/load_density_menu/build_load_density_menu.py +120 -0
  38. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/mail_thunder_menu/__init__.py +0 -0
  39. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/mail_thunder_menu/build_mail_thunder_menu.py +88 -0
  40. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/web_runner_menu/__init__.py +0 -0
  41. test_pioneer/test_pioneer_editor_ui/menu/automation_menu/web_runner_menu/build_webrunner_menu.py +119 -0
  42. test_pioneer/test_pioneer_editor_ui/menu/build_menubar.py +42 -0
  43. test_pioneer/test_pioneer_editor_ui/menu/install_menu/__init__.py +0 -0
  44. test_pioneer/test_pioneer_editor_ui/menu/install_menu/automation_menu/__init__.py +0 -0
  45. test_pioneer/test_pioneer_editor_ui/menu/install_menu/automation_menu/build_automation_install_menu.py +82 -0
  46. test_pioneer/test_pioneer_editor_ui/menu/install_menu/install_utils.py +21 -0
  47. test_pioneer/test_pioneer_editor_ui/menu/install_menu/tools_menu/__init__.py +0 -0
  48. test_pioneer/test_pioneer_editor_ui/menu/install_menu/tools_menu/build_tool_install_menu.py +29 -0
  49. test_pioneer/test_pioneer_editor_ui/menu/menu_utils.py +16 -0
  50. test_pioneer/test_pioneer_editor_ui/menu/tools_menu/__init__.py +0 -0
  51. test_pioneer/test_pioneer_editor_ui/menu/tools_menu/bing_gpt_menu/__init__.py +0 -0
  52. test_pioneer/test_pioneer_editor_ui/menu/tools_menu/bing_gpt_menu/build_bing_gpt_menu.py +44 -0
  53. test_pioneer/test_pioneer_editor_ui/show_code_window/__init__.py +0 -0
  54. test_pioneer/test_pioneer_editor_ui/show_code_window/code_window.py +21 -0
  55. test_pioneer/test_pioneer_editor_ui/syntax/__init__.py +0 -0
  56. test_pioneer/test_pioneer_editor_ui/syntax/syntax_extend.py +37 -0
  57. test_pioneer/test_pioneer_editor_ui/syntax/syntax_keyword.py +152 -0
  58. test_pioneer/utils/__init__.py +0 -0
  59. test_pioneer/utils/exception/__init__.py +0 -0
  60. test_pioneer/utils/exception/exception_tags.py +30 -0
  61. test_pioneer/utils/exception/exceptions.py +50 -0
  62. test_pioneer/utils/file_process/__init__.py +0 -0
  63. test_pioneer/utils/file_process/get_dir_file_list.py +29 -0
  64. test_pioneer/utils/json_format/__init__.py +1 -0
  65. test_pioneer/utils/json_format/json_process.py +28 -0
  66. test_pioneer/utils/logging/__init__.py +0 -0
  67. test_pioneer/utils/logging/loggin_instance.py +25 -0
  68. test_pioneer/utils/manager/__init__.py +0 -0
  69. test_pioneer/utils/manager/package_manager/__init__.py +0 -0
  70. test_pioneer/utils/manager/package_manager/package_manager_class.py +18 -0
  71. test_pioneer_dev-0.0.38.dist-info/LICENSE +21 -0
  72. test_pioneer_dev-0.0.38.dist-info/METADATA +87 -0
  73. test_pioneer_dev-0.0.38.dist-info/RECORD +75 -0
  74. test_pioneer_dev-0.0.38.dist-info/WHEEL +5 -0
  75. test_pioneer_dev-0.0.38.dist-info/top_level.txt +1 -0
@@ -0,0 +1,7 @@
1
+ from test_pioneer.test_pioneer_editor_ui.editor_main.main_ui import AutomationEditor
2
+ from test_pioneer.test_pioneer_editor_ui.editor_main.main_ui import EDITOR_EXTEND_TAB
3
+ from test_pioneer.test_pioneer_editor_ui.editor_main.main_ui import start_editor
4
+
5
+ __all__ = [
6
+ "start_editor", "AutomationEditor", "EDITOR_EXTEND_TAB"
7
+ ]
File without changes
File without changes
File without changes
@@ -0,0 +1,36 @@
1
+ import sys
2
+ from email.mime.multipart import MIMEMultipart
3
+
4
+ from test_pioneer.utils.exception.exception_tags import send_html_exception_tag
5
+ from test_pioneer.utils.exception.exceptions import ITESendHtmlReportException
6
+
7
+
8
+ def send_after_test(html_report_path: str = None) -> None:
9
+ try:
10
+ from je_mail_thunder import SMTPWrapper
11
+ mail_thunder_smtp: SMTPWrapper = SMTPWrapper()
12
+ if html_report_path is None and mail_thunder_smtp.login_state is True:
13
+ user: str = mail_thunder_smtp.user
14
+ with open("default_name.html", "r+") as file:
15
+ html_string: str = file.read()
16
+ message = mail_thunder_smtp.create_message_with_attach(
17
+ html_string,
18
+ {"Subject": "Test Report", "To": user, "From": user},
19
+ "default_name.html", use_html=True)
20
+ mail_thunder_smtp.send_message(message)
21
+ mail_thunder_smtp.quit()
22
+ elif mail_thunder_smtp.login_state is True:
23
+ user: str = mail_thunder_smtp.user
24
+ with open(html_report_path, "r+") as file:
25
+ html_string: str = file.read()
26
+ message: MIMEMultipart = mail_thunder_smtp.create_message_with_attach(
27
+ html_string,
28
+ {"Subject": "Test Report", "To": user, "From": user},
29
+ html_report_path, use_html=True)
30
+ mail_thunder_smtp.send_message(message)
31
+ mail_thunder_smtp.quit()
32
+ else:
33
+ raise ITESendHtmlReportException
34
+ except ITESendHtmlReportException as error:
35
+ print(repr(error), file=sys.stderr)
36
+ print(send_html_exception_tag, file=sys.stderr)
File without changes
@@ -0,0 +1,66 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Union
4
+
5
+ from test_pioneer.extend.process_executor.process_executor_utils import build_process
6
+
7
+ if TYPE_CHECKING:
8
+ from test_pioneer.test_pioneer_editor_ui.editor_main.main_ui import AutomationEditor
9
+ import sys
10
+
11
+ from test_pioneer.utils.file_process.get_dir_file_list import ask_and_get_dir_files_as_list
12
+
13
+
14
+ def call_api_testka(
15
+ main_window: AutomationEditor,
16
+ exec_str: Union[str, None] = None,
17
+ program_buffer: int = 1024000
18
+ ):
19
+ build_process(main_window, "je_api_testka", exec_str, False, program_buffer)
20
+
21
+
22
+ def call_api_testka_with_send(
23
+ main_window: AutomationEditor,
24
+ exec_str: Union[str, None] = None,
25
+ program_buffer: int = 1024000
26
+ ):
27
+ build_process(main_window, "je_api_testka", exec_str, True, program_buffer)
28
+
29
+
30
+ def call_api_testka_multi_file(
31
+ main_window: AutomationEditor,
32
+ program_buffer: int = 1024000
33
+ ):
34
+ try:
35
+ need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
36
+ if need_to_execute_list is not None \
37
+ and isinstance(need_to_execute_list, list) and len(need_to_execute_list) > 0:
38
+ for execute_file in need_to_execute_list:
39
+ with open(execute_file, "r+") as test_script_json:
40
+ call_api_testka(
41
+ main_window,
42
+ test_script_json.read(),
43
+ program_buffer
44
+ )
45
+ except Exception as error:
46
+ print(repr(error), file=sys.stderr)
47
+
48
+
49
+ def call_api_testka_multi_file_and_send(
50
+ main_window: AutomationEditor,
51
+ program_buffer: int = 1024000
52
+ ):
53
+ try:
54
+
55
+ need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
56
+ if need_to_execute_list is not None \
57
+ and isinstance(need_to_execute_list, list) and len(need_to_execute_list) > 0:
58
+ for execute_file in need_to_execute_list:
59
+ with open(execute_file, "r+") as test_script_json:
60
+ call_api_testka_with_send(
61
+ main_window,
62
+ test_script_json.read(),
63
+ program_buffer
64
+ )
65
+ except Exception as error:
66
+ print(repr(error), file=sys.stderr)
@@ -0,0 +1,62 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Union
4
+
5
+ from test_pioneer.extend.process_executor.process_executor_utils import build_process
6
+
7
+ if TYPE_CHECKING:
8
+ from test_pioneer.test_pioneer_editor_ui.editor_main.main_ui import AutomationEditor
9
+ import sys
10
+
11
+ from test_pioneer.utils.file_process.get_dir_file_list import ask_and_get_dir_files_as_list
12
+
13
+
14
+ def call_auto_control(
15
+ main_window: AutomationEditor,
16
+ exec_str: Union[str, None] = None,
17
+ program_buffer: int = 1024000
18
+ ):
19
+ build_process(main_window, "je_auto_control", exec_str, False, program_buffer)
20
+
21
+
22
+ def call_auto_control_with_send(
23
+ main_window: AutomationEditor,
24
+ exec_str: Union[str, None] = None,
25
+ program_buffer: int = 1024000
26
+ ):
27
+ build_process(main_window, "je_auto_control", exec_str, True, program_buffer)
28
+
29
+
30
+ def call_auto_control_multi_file(
31
+ main_window: AutomationEditor,
32
+ program_buffer: int = 1024000
33
+ ):
34
+ need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
35
+ if need_to_execute_list is not None \
36
+ and isinstance(need_to_execute_list, list) and len(need_to_execute_list) > 0:
37
+ for execute_file in need_to_execute_list:
38
+ with open(execute_file, "r+") as test_script_json:
39
+ call_auto_control(
40
+ main_window,
41
+ test_script_json.read(),
42
+ program_buffer
43
+ )
44
+
45
+
46
+ def call_auto_control_multi_file_and_send(
47
+ main_window: AutomationEditor,
48
+ program_buffer: int = 1024000
49
+ ):
50
+ try:
51
+ need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
52
+ if need_to_execute_list is not None \
53
+ and isinstance(need_to_execute_list, list) and len(need_to_execute_list) > 0:
54
+ for execute_file in need_to_execute_list:
55
+ with open(execute_file, "r+") as test_script_json:
56
+ call_auto_control_with_send(
57
+ main_window,
58
+ test_script_json.read(),
59
+ program_buffer
60
+ )
61
+ except Exception as error:
62
+ print(repr(error), file=sys.stderr)
@@ -0,0 +1,66 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Union
4
+
5
+ from test_pioneer.extend.process_executor.process_executor_utils import build_process
6
+
7
+ if TYPE_CHECKING:
8
+ from test_pioneer.test_pioneer_editor_ui.editor_main.main_ui import AutomationEditor
9
+ import sys
10
+
11
+ from test_pioneer.utils.file_process.get_dir_file_list import ask_and_get_dir_files_as_list
12
+
13
+
14
+ def call_file_automation_test(
15
+ main_window: AutomationEditor,
16
+ exec_str: Union[str, None] = None,
17
+ program_buffer: int = 1024000
18
+ ):
19
+ build_process(main_window, "automation_file", exec_str, False, program_buffer)
20
+
21
+
22
+ def call_file_automation_test_with_send(
23
+ main_window: AutomationEditor,
24
+ exec_str: Union[str, None] = None,
25
+ program_buffer: int = 1024000
26
+ ):
27
+ build_process(main_window, "automation_file", exec_str, True, program_buffer)
28
+
29
+
30
+ def call_file_automation_test_multi_file(
31
+ main_window: AutomationEditor,
32
+ program_buffer: int = 1024000
33
+ ):
34
+ try:
35
+ need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
36
+ if need_to_execute_list is not None \
37
+ and isinstance(need_to_execute_list, list) and len(need_to_execute_list) > 0:
38
+ for execute_file in need_to_execute_list:
39
+ with open(execute_file, "r+") as test_script_json:
40
+ call_file_automation_test(
41
+ main_window,
42
+ test_script_json.read(),
43
+ program_buffer
44
+ )
45
+ except Exception as error:
46
+ print(repr(error), file=sys.stderr)
47
+
48
+
49
+ def call_file_automation_test_multi_file_and_send(
50
+ main_window: AutomationEditor,
51
+ program_buffer: int = 1024000
52
+ ):
53
+ try:
54
+
55
+ need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
56
+ if need_to_execute_list is not None \
57
+ and isinstance(need_to_execute_list, list) and len(need_to_execute_list) > 0:
58
+ for execute_file in need_to_execute_list:
59
+ with open(execute_file, "r+") as test_script_json:
60
+ call_file_automation_test_with_send(
61
+ main_window,
62
+ test_script_json.read(),
63
+ program_buffer
64
+ )
65
+ except Exception as error:
66
+ print(repr(error), file=sys.stderr)
@@ -0,0 +1,66 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Union
4
+
5
+ from test_pioneer.extend.process_executor.process_executor_utils import build_process
6
+
7
+ if TYPE_CHECKING:
8
+ from test_pioneer.test_pioneer_editor_ui.editor_main.main_ui import AutomationEditor
9
+ import sys
10
+
11
+ from test_pioneer.utils.file_process.get_dir_file_list import ask_and_get_dir_files_as_list
12
+
13
+
14
+ def call_load_density(
15
+ main_window: AutomationEditor,
16
+ exec_str: Union[str, None] = None,
17
+ program_buffer: int = 1024000
18
+ ):
19
+ build_process(main_window, "je_load_density", exec_str, False, program_buffer)
20
+
21
+
22
+ def call_load_density_with_send(
23
+ main_window: AutomationEditor,
24
+ exec_str: Union[str, None] = None,
25
+ program_buffer: int = 1024000
26
+ ):
27
+ build_process(main_window, "je_load_density", exec_str, True, program_buffer)
28
+
29
+
30
+ def call_load_density_multi_file(
31
+ main_window: AutomationEditor,
32
+ program_buffer: int = 1024000
33
+ ):
34
+ try:
35
+ need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
36
+ if need_to_execute_list is not None and isinstance(need_to_execute_list, list) and len(
37
+ need_to_execute_list) > 0:
38
+ for execute_file in need_to_execute_list:
39
+ with open(execute_file, "r+") as test_script_json:
40
+ call_load_density(
41
+ main_window,
42
+ test_script_json.read(),
43
+ program_buffer
44
+ )
45
+ except Exception as error:
46
+ print(repr(error), file=sys.stderr)
47
+
48
+
49
+ def call_load_density_multi_file_and_send(
50
+ main_window: AutomationEditor,
51
+ program_buffer: int = 1024000
52
+ ):
53
+ try:
54
+
55
+ need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
56
+ if need_to_execute_list is not None and isinstance(need_to_execute_list, list) and len(
57
+ need_to_execute_list) > 0:
58
+ for execute_file in need_to_execute_list:
59
+ with open(execute_file, "r+") as test_script_json:
60
+ call_load_density_with_send(
61
+ main_window,
62
+ test_script_json.read(),
63
+ program_buffer
64
+ )
65
+ except Exception as error:
66
+ print(repr(error), file=sys.stderr)
@@ -0,0 +1,16 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Union
4
+
5
+ from test_pioneer.extend.process_executor.process_executor_utils import build_process
6
+
7
+ if TYPE_CHECKING:
8
+ from test_pioneer.test_pioneer_editor_ui.editor_main.main_ui import AutomationEditor
9
+
10
+
11
+ def call_mail_thunder(
12
+ main_window: AutomationEditor,
13
+ exec_str: Union[str, None] = None,
14
+ program_buffer: int = 1024000
15
+ ):
16
+ build_process(main_window, "je_mail_thunder", exec_str, False, program_buffer)
@@ -0,0 +1,72 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import sys
5
+ from typing import TYPE_CHECKING, Union
6
+
7
+ from je_editor import EditorWidget
8
+
9
+ from test_pioneer.test_pioneer_editor_ui.show_code_window.code_window import CodeWindow
10
+ from test_pioneer.extend.mail_thunder_extend.mail_thunder_setting import send_after_test
11
+ from test_pioneer.extend.process_executor.task_process_manager import TaskProcessManager
12
+ from test_pioneer.utils.exception.exception_tags import wrong_test_data_format_exception_tag
13
+ from test_pioneer.utils.exception.exceptions import ITETestExecutorException
14
+
15
+ if TYPE_CHECKING:
16
+ from test_pioneer.test_pioneer_editor_ui.editor_main.main_ui import AutomationEditor
17
+
18
+
19
+ def build_process(
20
+ main_window: AutomationEditor,
21
+ package: str,
22
+ exec_str: Union[str, None] = None,
23
+ send_mail: bool = False,
24
+ program_buffer: int = 1024000,
25
+ ):
26
+ try:
27
+ widget = main_window.tab_widget.currentWidget()
28
+ if isinstance(widget, EditorWidget) and exec_str is None:
29
+ test_format_code = widget.code_edit.toPlainText()
30
+ else:
31
+ test_format_code = exec_str
32
+ start_process(main_window, package, test_format_code, send_mail, program_buffer)
33
+ except json.decoder.JSONDecodeError as error:
34
+ print(
35
+ repr(error) +
36
+ "\n"
37
+ + wrong_test_data_format_exception_tag,
38
+ file=sys.stderr
39
+ )
40
+ except ITETestExecutorException as error:
41
+ print(repr(error), file=sys.stderr)
42
+
43
+
44
+ def start_process(
45
+ main_window: AutomationEditor,
46
+ package: str,
47
+ test_format_code: str,
48
+ send_mail: bool = False,
49
+ program_buffer: int = 1024000
50
+ ):
51
+ # Code window init
52
+ code_window = CodeWindow()
53
+ main_window.current_run_code_window.append(code_window)
54
+ main_window.clear_code_result()
55
+ # Process init
56
+ if send_mail:
57
+ process = TaskProcessManager(
58
+ main_window=code_window,
59
+ program_buffer_size=program_buffer,
60
+ program_encoding=main_window.encoding
61
+ )
62
+ else:
63
+ process = TaskProcessManager(
64
+ code_window,
65
+ task_done_trigger_function=send_after_test,
66
+ program_buffer_size=program_buffer,
67
+ program_encoding=main_window.encoding
68
+ )
69
+ process.start_test_process(
70
+ package,
71
+ exec_str=test_format_code,
72
+ )
@@ -0,0 +1,164 @@
1
+ import json
2
+ import queue
3
+ import subprocess
4
+ import sys
5
+ import threading
6
+ import typing
7
+ from pathlib import Path
8
+ from queue import Queue
9
+ from threading import Thread
10
+
11
+ from PySide6.QtCore import QTimer
12
+ from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict
13
+ from je_editor.utils.venv_check.check_venv import check_and_choose_venv
14
+
15
+ from test_pioneer.test_pioneer_editor_ui.show_code_window.code_window import CodeWindow
16
+
17
+
18
+ class TaskProcessManager(object):
19
+ def __init__(
20
+ self,
21
+ main_window: CodeWindow,
22
+ task_done_trigger_function: typing.Callable = None,
23
+ error_trigger_function: typing.Callable = None,
24
+ program_buffer_size: int = 1024,
25
+ program_encoding: str = "utf-8"
26
+ ):
27
+ super().__init__()
28
+ self.compiler_path = None
29
+ # ite_instance param
30
+ self.read_program_error_output_from_thread: [threading.Thread, None] = None
31
+ self.read_program_output_from_thread: [threading.Thread, None] = None
32
+ self.main_window: CodeWindow = main_window
33
+ self.timer: QTimer = QTimer(self.main_window)
34
+ self.still_run_program: bool = True
35
+ self.program_encoding: str = program_encoding
36
+ self.run_output_queue: Queue = Queue()
37
+ self.run_error_queue: Queue = Queue()
38
+ self.process: [subprocess.Popen, None] = None
39
+
40
+ self.task_done_trigger_function: typing.Callable = task_done_trigger_function
41
+ self.error_trigger_function: typing.Callable = error_trigger_function
42
+ self.program_buffer_size = program_buffer_size
43
+
44
+ def renew_path(self) -> None:
45
+ if self.main_window.python_compiler is None:
46
+ # Renew compiler path
47
+ if sys.platform in ["win32", "cygwin", "msys"]:
48
+ venv_path = Path(str(Path.cwd()) + "/venv/Scripts")
49
+ else:
50
+ venv_path = Path(str(Path.cwd()) + "/venv/bin")
51
+ self.compiler_path = check_and_choose_venv(venv_path)
52
+ else:
53
+ self.compiler_path = self.main_window.python_compiler
54
+
55
+ def start_test_process(self, package: str, exec_str: str):
56
+ self.renew_path()
57
+ if sys.platform in ["win32", "cygwin", "msys"]:
58
+ exec_str = json.dumps(exec_str)
59
+ args = [
60
+ self.compiler_path,
61
+ "-m",
62
+ package,
63
+ "--execute_str",
64
+ exec_str
65
+ ]
66
+ else:
67
+ args = " ".join([f"{self.compiler_path}", f"-m {package}", "--execute_str", f"{exec_str}"])
68
+ self.process: subprocess.Popen = subprocess.Popen(
69
+ args,
70
+ stdin=subprocess.PIPE,
71
+ stdout=subprocess.PIPE,
72
+ stderr=subprocess.PIPE,
73
+ shell=True,
74
+ encoding=self.program_encoding
75
+ )
76
+ self.still_run_program = True
77
+ # program output message queue thread
78
+ self.read_program_output_from_thread = Thread(
79
+ target=self.read_program_output_from_process,
80
+ daemon=True
81
+ )
82
+ self.read_program_output_from_thread.start()
83
+ # program error message queue thread
84
+ self.read_program_error_output_from_thread = Thread(
85
+ target=self.read_program_error_output_from_process,
86
+ daemon=True
87
+ )
88
+ self.read_program_error_output_from_thread.start()
89
+ # start Pyside update
90
+ # start timer
91
+ self.main_window.setWindowTitle(package)
92
+ self.main_window.show()
93
+ self.timer = QTimer()
94
+ self.timer.setInterval(100)
95
+ self.timer.timeout.connect(self.pull_text)
96
+ self.timer.start()
97
+
98
+ # Pyside UI update method
99
+ def pull_text(self):
100
+ try:
101
+ self.main_window.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
102
+ if not self.run_output_queue.empty():
103
+ output_message = self.run_output_queue.get_nowait()
104
+ output_message = str(output_message).strip()
105
+ if output_message:
106
+ self.main_window.code_result.append(output_message)
107
+ self.main_window.code_result.setTextColor(actually_color_dict.get("error_output_color"))
108
+ if not self.run_error_queue.empty():
109
+ error_message = self.run_error_queue.get_nowait()
110
+ error_message = str(error_message).strip()
111
+ if error_message:
112
+ self.main_window.code_result.append(error_message)
113
+ self.main_window.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
114
+ except queue.Empty:
115
+ pass
116
+ if self.process is not None:
117
+ if self.process.returncode == 0:
118
+ if self.timer.isActive():
119
+ self.timer.stop()
120
+ self.exit_program()
121
+ elif self.process.returncode is not None:
122
+ if self.timer.isActive():
123
+ self.timer.stop()
124
+ self.exit_program()
125
+ if self.still_run_program:
126
+ # poll return code
127
+ self.process.poll()
128
+ else:
129
+ if self.timer.isActive():
130
+ self.timer.stop()
131
+
132
+ # exit program change run flag to false and clean read thread and queue and process
133
+ def exit_program(self):
134
+ self.still_run_program = False
135
+ if self.read_program_output_from_thread is not None:
136
+ self.read_program_output_from_thread = None
137
+ if self.read_program_error_output_from_thread is not None:
138
+ self.read_program_error_output_from_thread = None
139
+ self.print_and_clear_queue()
140
+ if self.process is not None:
141
+ self.process.terminate()
142
+ self.main_window.code_result.append(f"Task exit with code {self.process.returncode}")
143
+ self.process = None
144
+
145
+ def print_and_clear_queue(self):
146
+ self.run_output_queue = queue.Queue()
147
+ self.run_error_queue = queue.Queue()
148
+
149
+ def read_program_output_from_process(self):
150
+ while self.still_run_program:
151
+ self.process: subprocess.Popen
152
+ program_output_data = self.process.stdout.read(self.program_buffer_size)
153
+ if self.process:
154
+ self.process.stdout.flush()
155
+ if program_output_data.strip() != "":
156
+ self.run_output_queue.put(program_output_data)
157
+
158
+ def read_program_error_output_from_process(self):
159
+ while self.still_run_program:
160
+ program_error_output_data = self.process.stderr.read(self.program_buffer_size)
161
+ if self.process:
162
+ self.process.stderr.flush()
163
+ if program_error_output_data.strip() != "":
164
+ self.run_error_queue.put(program_error_output_data)
@@ -0,0 +1,66 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Union
4
+
5
+ from test_pioneer.extend.process_executor.process_executor_utils import build_process
6
+
7
+ if TYPE_CHECKING:
8
+ from test_pioneer.test_pioneer_editor_ui.editor_main.main_ui import AutomationEditor
9
+ import sys
10
+
11
+ from test_pioneer.utils.file_process.get_dir_file_list import ask_and_get_dir_files_as_list
12
+
13
+
14
+ def call_web_runner_test(
15
+ main_window: AutomationEditor,
16
+ exec_str: Union[str, None] = None,
17
+ program_buffer: int = 1024000
18
+ ):
19
+ build_process(main_window, "je_web_runner", exec_str, False, program_buffer)
20
+
21
+
22
+ def call_web_runner_test_with_send(
23
+ main_window: AutomationEditor,
24
+ exec_str: Union[str, None] = None,
25
+ program_buffer: int = 1024000
26
+ ):
27
+ build_process(main_window, "je_web_runner", exec_str, True, program_buffer)
28
+
29
+
30
+ def call_web_runner_test_multi_file(
31
+ main_window: AutomationEditor,
32
+ program_buffer: int = 1024000
33
+ ):
34
+ try:
35
+ need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
36
+ if need_to_execute_list is not None and isinstance(need_to_execute_list, list) and len(
37
+ need_to_execute_list) > 0:
38
+ for execute_file in need_to_execute_list:
39
+ with open(execute_file, "r+") as test_script_json:
40
+ call_web_runner_test(
41
+ main_window,
42
+ test_script_json.read(),
43
+ program_buffer
44
+ )
45
+ except Exception as error:
46
+ print(repr(error), file=sys.stderr)
47
+
48
+
49
+ def call_web_runner_test_multi_file_and_send(
50
+ main_window: AutomationEditor,
51
+ program_buffer: int = 1024000
52
+ ):
53
+ try:
54
+
55
+ need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
56
+ if need_to_execute_list is not None and isinstance(need_to_execute_list, list) and len(
57
+ need_to_execute_list) > 0:
58
+ for execute_file in need_to_execute_list:
59
+ with open(execute_file, "r+") as test_script_json:
60
+ call_web_runner_test_with_send(
61
+ main_window,
62
+ test_script_json.read(),
63
+ program_buffer
64
+ )
65
+ except Exception as error:
66
+ print(repr(error), file=sys.stderr)
File without changes