diff --git a/automation_ide/automation_editor_ui/menu/automation_menu/auto_control_menu/build_autocontrol_menu.py b/automation_ide/automation_editor_ui/menu/automation_menu/auto_control_menu/build_autocontrol_menu.py index 8e8e95c..92ee26d 100644 --- a/automation_ide/automation_editor_ui/menu/automation_menu/auto_control_menu/build_autocontrol_menu.py +++ b/automation_ide/automation_editor_ui/menu/automation_menu/auto_control_menu/build_autocontrol_menu.py @@ -4,6 +4,7 @@ from je_auto_control.gui.main_widget import AutoControlGUIWidget from je_editor import EditorWidget, language_wrapper +from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict from automation_ide.automation_editor_ui.menu.menu_utils import open_web_browser @@ -12,7 +13,7 @@ import sys import je_auto_control -from PySide6.QtGui import QAction +from PySide6.QtGui import QAction, QTextCharFormat from automation_ide.extend.process_executor.auto_control.auto_control_process import \ call_auto_control, call_auto_control_with_send, call_auto_control_multi_file, \ @@ -155,7 +156,11 @@ def create_project() -> None: def stop_record(editor_instance: AutomationEditor): widget = editor_instance.tab_widget.currentWidget() if isinstance(widget, EditorWidget): - widget.code_edit.appendPlainText(str(je_auto_control.stop_record())) + text_cursor = widget.code_edit.textCursor() + text_format = QTextCharFormat() + text_format.setForeground(actually_color_dict.get("normal_output_color")) + text_cursor.insertText(str(je_auto_control.stop_record()), text_format) + text_cursor.insertBlock() def add_autocontrol_gui(ui_we_want_to_set: AutomationEditor) -> None: diff --git a/automation_ide/extend/process_executor/python_task_process_manager.py b/automation_ide/extend/process_executor/python_task_process_manager.py index 5061f94..9901284 100644 --- a/automation_ide/extend/process_executor/python_task_process_manager.py +++ b/automation_ide/extend/process_executor/python_task_process_manager.py @@ -7,8 +7,10 @@ from pathlib import Path from queue import Queue from threading import Thread +from typing import Union from PySide6.QtCore import QTimer +from PySide6.QtGui import QTextCharFormat from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict from je_editor.utils.venv_check.check_venv import check_and_choose_venv @@ -27,15 +29,15 @@ def __init__( super().__init__() self.compiler_path = None # ite_instance param - self.read_program_error_output_from_thread: [threading.Thread, None] = None - self.read_program_output_from_thread: [threading.Thread, None] = None + self.read_program_error_output_from_thread: Union[threading.Thread, None] = None + self.read_program_output_from_thread: Union[threading.Thread, None] = None self.main_window: CodeWindow = main_window self.timer: QTimer = QTimer(self.main_window) self.still_run_program: bool = True self.program_encoding: str = program_encoding self.run_output_queue: Queue = Queue() self.run_error_queue: Queue = Queue() - self.process: [subprocess.Popen, None] = None + self.process: Union[subprocess.Popen, None] = None self.task_done_trigger_function: typing.Callable = task_done_trigger_function self.error_trigger_function: typing.Callable = error_trigger_function @@ -98,19 +100,24 @@ def start_test_process(self, package: str, exec_str: str): # Pyside UI update method def pull_text(self): try: - self.main_window.code_result.setTextColor(actually_color_dict.get("normal_output_color")) if not self.run_output_queue.empty(): output_message = self.run_output_queue.get_nowait() output_message = str(output_message).strip() if output_message: - self.main_window.code_result.append(output_message) - self.main_window.code_result.setTextColor(actually_color_dict.get("error_output_color")) + text_cursor = self.main_window.code_result.textCursor() + text_format = QTextCharFormat() + text_format.setForeground(actually_color_dict.get("normal_output_color")) + text_cursor.insertText(output_message, text_format) + text_cursor.insertBlock() if not self.run_error_queue.empty(): error_message = self.run_error_queue.get_nowait() error_message = str(error_message).strip() if error_message: - self.main_window.code_result.append(error_message) - self.main_window.code_result.setTextColor(actually_color_dict.get("normal_output_color")) + text_cursor = self.main_window.code_result.textCursor() + text_format = QTextCharFormat() + text_format.setForeground(actually_color_dict.get("error_output_color")) + text_cursor.insertText(error_message, text_format) + text_cursor.insertBlock() except queue.Empty: pass if self.process is not None: @@ -139,7 +146,11 @@ def exit_program(self): self.print_and_clear_queue() if self.process is not None: self.process.terminate() - self.main_window.code_result.append(f"Task exit with code {self.process.returncode}") + text_cursor = self.main_window.code_result.textCursor() + text_format = QTextCharFormat() + text_format.setForeground(actually_color_dict.get("normal_output_color")) + text_cursor.insertText(f"Task exit with code {self.process.returncode}", text_format) + text_cursor.insertBlock() self.process = None def print_and_clear_queue(self): @@ -149,7 +160,8 @@ def print_and_clear_queue(self): def read_program_output_from_process(self): while self.still_run_program: self.process: subprocess.Popen - program_output_data = self.process.stdout.read(self.program_buffer_size) + program_output_data = self.process.stdout.readline(self.program_buffer_size)\ + .decode("utf-8", "replace") if self.process: self.process.stdout.flush() if program_output_data.strip() != "": @@ -157,7 +169,8 @@ def read_program_output_from_process(self): def read_program_error_output_from_process(self): while self.still_run_program: - program_error_output_data = self.process.stderr.read(self.program_buffer_size) + program_error_output_data = self.process.stderr.readline(self.program_buffer_size)\ + .decode("utf-8", "replace") if self.process: self.process.stderr.flush() if program_error_output_data.strip() != "": diff --git a/automation_ide/extend/process_executor/test_pioneer/test_pioneer_process_manager.py b/automation_ide/extend/process_executor/test_pioneer/test_pioneer_process_manager.py index 87a1d4f..047a9b4 100644 --- a/automation_ide/extend/process_executor/test_pioneer/test_pioneer_process_manager.py +++ b/automation_ide/extend/process_executor/test_pioneer/test_pioneer_process_manager.py @@ -6,9 +6,10 @@ import threading from pathlib import Path from queue import Queue -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Union from PySide6.QtCore import QTimer +from PySide6.QtGui import QTextCharFormat from PySide6.QtWidgets import QWidget from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict from je_editor.utils.venv_check.check_venv import check_and_choose_venv @@ -38,8 +39,8 @@ def __init__( self._program_buffer_size = program_buffer self._run_output_queue: Queue = Queue() self._run_error_queue: Queue = Queue() - self._read_program_error_output_from_thread: [threading.Thread, None] = None - self._read_program_output_from_thread: [threading.Thread, None] = None + self._read_program_error_output_from_thread: Union[threading.Thread, None] = None + self._read_program_output_from_thread: Union[threading.Thread, None] = None self._timer: QTimer = QTimer(self._code_window) if self._main_window.python_compiler is None: # Renew compiler path @@ -74,19 +75,24 @@ def __init__( # Pyside UI update method def pull_text(self): try: - self._code_window.code_result.setTextColor(actually_color_dict.get("normal_output_color")) if not self._run_output_queue.empty(): output_message = self._run_output_queue.get_nowait() output_message = str(output_message).strip() if output_message: - self._code_window.code_result.append(output_message) - self._code_window.code_result.setTextColor(actually_color_dict.get("error_output_color")) + text_cursor = self._code_window.code_result.textCursor() + text_format = QTextCharFormat() + text_format.setForeground(actually_color_dict.get("normal_output_color")) + text_cursor.insertText(output_message, text_format) + text_cursor.insertBlock() if not self._run_error_queue.empty(): error_message = self._run_error_queue.get_nowait() error_message = str(error_message).strip() if error_message: - self._code_window.code_result.append(error_message) - self._code_window.code_result.setTextColor(actually_color_dict.get("normal_output_color")) + text_cursor = self._code_window.code_result.textCursor() + text_format = QTextCharFormat() + text_format.setForeground(actually_color_dict.get("error_output_color")) + text_cursor.insertText(error_message, text_format) + text_cursor.insertBlock() except queue.Empty: pass if self._process is not None: @@ -115,7 +121,11 @@ def exit_program(self): self.print_and_clear_queue() if self._process is not None: self._process.terminate() - self._code_window.code_result.append(f"Task exit with code {self._process.returncode}") + text_cursor = self._code_window.code_result.textCursor() + text_format = QTextCharFormat() + text_format.setForeground(actually_color_dict.get("normal_output_color")) + text_cursor.insertText(f"Task exit with code {self._process.returncode}", text_format) + text_cursor.insertBlock() self._process = None def print_and_clear_queue(self): @@ -125,7 +135,8 @@ def print_and_clear_queue(self): def read_program_output_from_process(self): while self._still_run_program: self.process: subprocess.Popen - program_output_data = self._process.stdout.read(self._program_buffer_size) + program_output_data = self._process.stdout.readline(self._program_buffer_size)\ + .decode("utf-8", "replace") if self._process: self._process.stdout.flush() if program_output_data.strip() != "": @@ -133,7 +144,8 @@ def read_program_output_from_process(self): def read_program_error_output_from_process(self): while self._still_run_program: - program_error_output_data = self._process.stderr.read(self._program_buffer_size) + program_error_output_data = self._process.stderr.readline(self._program_buffer_size)\ + .decode("utf-8", "replace") if self._process: self._process.stderr.flush() if program_error_output_data.strip() != "": diff --git a/stable.toml b/dev.toml similarity index 86% rename from stable.toml rename to dev.toml index c338fb9..cb2ce2d 100644 --- a/stable.toml +++ b/dev.toml @@ -1,12 +1,12 @@ -# Rename to build stable version -# This is stable version +# Rename to dev version +# This is dev version [build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] -name = "automation_ide" -version = "0.0.44" +name = "automation_ide_dev" +version = "0.0.52" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ] @@ -16,7 +16,7 @@ license-files = ["LICENSE"] dependencies = [ "je-editor", "je_auto_control", "je_web_runner", "je_load_density", "je_api_testka", "je-mail-thunder", - "automation-file", "PySide6==6.9.1", "test_pioneer" + "automation-file", "PySide6==6.9.2", "test_pioneer" ] classifiers = [ "Programming Language :: Python :: 3.10", @@ -35,5 +35,6 @@ Code = "https://github.com/Intergration-Automation-Testing/AutomationEditor" file = "README.md" content-type = "text/markdown" + [tool.setuptools.packages] find = { namespaces = false } diff --git a/dev_requirements.txt b/dev_requirements.txt index c2bad87..3950254 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -8,6 +8,6 @@ je-mail-thunder automation_ide_dev sphinx sphinx-rtd-theme -PySide6==6.9.1 +PySide6==6.9.2 auto-py-to-exe test_pioneer \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index e1286d2..bfd2c3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ -# Rename to dev version -# This is dev version +# Rename to build stable version +# This is stable version [build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] -name = "automation_ide_dev" -version = "0.0.49" +name = "automation_ide" +version = "0.0.46" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ] @@ -16,7 +16,7 @@ license-files = ["LICENSE"] dependencies = [ "je-editor", "je_auto_control", "je_web_runner", "je_load_density", "je_api_testka", "je-mail-thunder", - "automation-file", "PySide6==6.9.1", "test_pioneer" + "automation-file", "PySide6==6.9.2", "test_pioneer" ] classifiers = [ "Programming Language :: Python :: 3.10", @@ -35,6 +35,5 @@ Code = "https://github.com/Intergration-Automation-Testing/AutomationEditor" file = "README.md" content-type = "text/markdown" - [tool.setuptools.packages] find = { namespaces = false } diff --git a/requirements.txt b/requirements.txt index f9dfbfd..86f32bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ automation_ide -PySide6==6.9.1 +PySide6==6.9.2