Skip to content

Commit eb38755

Browse files
authored
Merge pull request #99 from Integration-Automation/dev
Dev
2 parents b36ad8b + f303176 commit eb38755

7 files changed

Lines changed: 67 additions & 37 deletions

File tree

automation_ide/automation_editor_ui/menu/automation_menu/auto_control_menu/build_autocontrol_menu.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from je_auto_control.gui.main_widget import AutoControlGUIWidget
66
from je_editor import EditorWidget, language_wrapper
7+
from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict
78

89
from automation_ide.automation_editor_ui.menu.menu_utils import open_web_browser
910

@@ -12,7 +13,7 @@
1213
import sys
1314

1415
import je_auto_control
15-
from PySide6.QtGui import QAction
16+
from PySide6.QtGui import QAction, QTextCharFormat
1617

1718
from automation_ide.extend.process_executor.auto_control.auto_control_process import \
1819
call_auto_control, call_auto_control_with_send, call_auto_control_multi_file, \
@@ -155,7 +156,11 @@ def create_project() -> None:
155156
def stop_record(editor_instance: AutomationEditor):
156157
widget = editor_instance.tab_widget.currentWidget()
157158
if isinstance(widget, EditorWidget):
158-
widget.code_edit.appendPlainText(str(je_auto_control.stop_record()))
159+
text_cursor = widget.code_edit.textCursor()
160+
text_format = QTextCharFormat()
161+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
162+
text_cursor.insertText(str(je_auto_control.stop_record()), text_format)
163+
text_cursor.insertBlock()
159164

160165

161166
def add_autocontrol_gui(ui_we_want_to_set: AutomationEditor) -> None:

automation_ide/extend/process_executor/python_task_process_manager.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
from pathlib import Path
88
from queue import Queue
99
from threading import Thread
10+
from typing import Union
1011

1112
from PySide6.QtCore import QTimer
13+
from PySide6.QtGui import QTextCharFormat
1214
from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict
1315
from je_editor.utils.venv_check.check_venv import check_and_choose_venv
1416

@@ -27,15 +29,15 @@ def __init__(
2729
super().__init__()
2830
self.compiler_path = None
2931
# 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.read_program_error_output_from_thread: Union[threading.Thread, None] = None
33+
self.read_program_output_from_thread: Union[threading.Thread, None] = None
3234
self.main_window: CodeWindow = main_window
3335
self.timer: QTimer = QTimer(self.main_window)
3436
self.still_run_program: bool = True
3537
self.program_encoding: str = program_encoding
3638
self.run_output_queue: Queue = Queue()
3739
self.run_error_queue: Queue = Queue()
38-
self.process: [subprocess.Popen, None] = None
40+
self.process: Union[subprocess.Popen, None] = None
3941

4042
self.task_done_trigger_function: typing.Callable = task_done_trigger_function
4143
self.error_trigger_function: typing.Callable = error_trigger_function
@@ -98,19 +100,24 @@ def start_test_process(self, package: str, exec_str: str):
98100
# Pyside UI update method
99101
def pull_text(self):
100102
try:
101-
self.main_window.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
102103
if not self.run_output_queue.empty():
103104
output_message = self.run_output_queue.get_nowait()
104105
output_message = str(output_message).strip()
105106
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"))
107+
text_cursor = self.main_window.code_result.textCursor()
108+
text_format = QTextCharFormat()
109+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
110+
text_cursor.insertText(output_message, text_format)
111+
text_cursor.insertBlock()
108112
if not self.run_error_queue.empty():
109113
error_message = self.run_error_queue.get_nowait()
110114
error_message = str(error_message).strip()
111115
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"))
116+
text_cursor = self.main_window.code_result.textCursor()
117+
text_format = QTextCharFormat()
118+
text_format.setForeground(actually_color_dict.get("error_output_color"))
119+
text_cursor.insertText(error_message, text_format)
120+
text_cursor.insertBlock()
114121
except queue.Empty:
115122
pass
116123
if self.process is not None:
@@ -139,7 +146,11 @@ def exit_program(self):
139146
self.print_and_clear_queue()
140147
if self.process is not None:
141148
self.process.terminate()
142-
self.main_window.code_result.append(f"Task exit with code {self.process.returncode}")
149+
text_cursor = self.main_window.code_result.textCursor()
150+
text_format = QTextCharFormat()
151+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
152+
text_cursor.insertText(f"Task exit with code {self.process.returncode}", text_format)
153+
text_cursor.insertBlock()
143154
self.process = None
144155

145156
def print_and_clear_queue(self):
@@ -149,15 +160,17 @@ def print_and_clear_queue(self):
149160
def read_program_output_from_process(self):
150161
while self.still_run_program:
151162
self.process: subprocess.Popen
152-
program_output_data = self.process.stdout.read(self.program_buffer_size)
163+
program_output_data = self.process.stdout.readline(self.program_buffer_size)\
164+
.decode("utf-8", "replace")
153165
if self.process:
154166
self.process.stdout.flush()
155167
if program_output_data.strip() != "":
156168
self.run_output_queue.put(program_output_data)
157169

158170
def read_program_error_output_from_process(self):
159171
while self.still_run_program:
160-
program_error_output_data = self.process.stderr.read(self.program_buffer_size)
172+
program_error_output_data = self.process.stderr.readline(self.program_buffer_size)\
173+
.decode("utf-8", "replace")
161174
if self.process:
162175
self.process.stderr.flush()
163176
if program_error_output_data.strip() != "":

automation_ide/extend/process_executor/test_pioneer/test_pioneer_process_manager.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
import threading
77
from pathlib import Path
88
from queue import Queue
9-
from typing import TYPE_CHECKING
9+
from typing import TYPE_CHECKING, Union
1010

1111
from PySide6.QtCore import QTimer
12+
from PySide6.QtGui import QTextCharFormat
1213
from PySide6.QtWidgets import QWidget
1314
from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict
1415
from je_editor.utils.venv_check.check_venv import check_and_choose_venv
@@ -38,8 +39,8 @@ def __init__(
3839
self._program_buffer_size = program_buffer
3940
self._run_output_queue: Queue = Queue()
4041
self._run_error_queue: Queue = Queue()
41-
self._read_program_error_output_from_thread: [threading.Thread, None] = None
42-
self._read_program_output_from_thread: [threading.Thread, None] = None
42+
self._read_program_error_output_from_thread: Union[threading.Thread, None] = None
43+
self._read_program_output_from_thread: Union[threading.Thread, None] = None
4344
self._timer: QTimer = QTimer(self._code_window)
4445
if self._main_window.python_compiler is None:
4546
# Renew compiler path
@@ -74,19 +75,24 @@ def __init__(
7475
# Pyside UI update method
7576
def pull_text(self):
7677
try:
77-
self._code_window.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
7878
if not self._run_output_queue.empty():
7979
output_message = self._run_output_queue.get_nowait()
8080
output_message = str(output_message).strip()
8181
if output_message:
82-
self._code_window.code_result.append(output_message)
83-
self._code_window.code_result.setTextColor(actually_color_dict.get("error_output_color"))
82+
text_cursor = self._code_window.code_result.textCursor()
83+
text_format = QTextCharFormat()
84+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
85+
text_cursor.insertText(output_message, text_format)
86+
text_cursor.insertBlock()
8487
if not self._run_error_queue.empty():
8588
error_message = self._run_error_queue.get_nowait()
8689
error_message = str(error_message).strip()
8790
if error_message:
88-
self._code_window.code_result.append(error_message)
89-
self._code_window.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
91+
text_cursor = self._code_window.code_result.textCursor()
92+
text_format = QTextCharFormat()
93+
text_format.setForeground(actually_color_dict.get("error_output_color"))
94+
text_cursor.insertText(error_message, text_format)
95+
text_cursor.insertBlock()
9096
except queue.Empty:
9197
pass
9298
if self._process is not None:
@@ -115,7 +121,11 @@ def exit_program(self):
115121
self.print_and_clear_queue()
116122
if self._process is not None:
117123
self._process.terminate()
118-
self._code_window.code_result.append(f"Task exit with code {self._process.returncode}")
124+
text_cursor = self._code_window.code_result.textCursor()
125+
text_format = QTextCharFormat()
126+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
127+
text_cursor.insertText(f"Task exit with code {self._process.returncode}", text_format)
128+
text_cursor.insertBlock()
119129
self._process = None
120130

121131
def print_and_clear_queue(self):
@@ -125,15 +135,17 @@ def print_and_clear_queue(self):
125135
def read_program_output_from_process(self):
126136
while self._still_run_program:
127137
self.process: subprocess.Popen
128-
program_output_data = self._process.stdout.read(self._program_buffer_size)
138+
program_output_data = self._process.stdout.readline(self._program_buffer_size)\
139+
.decode("utf-8", "replace")
129140
if self._process:
130141
self._process.stdout.flush()
131142
if program_output_data.strip() != "":
132143
self._run_output_queue.put(program_output_data)
133144

134145
def read_program_error_output_from_process(self):
135146
while self._still_run_program:
136-
program_error_output_data = self._process.stderr.read(self._program_buffer_size)
147+
program_error_output_data = self._process.stderr.readline(self._program_buffer_size)\
148+
.decode("utf-8", "replace")
137149
if self._process:
138150
self._process.stderr.flush()
139151
if program_error_output_data.strip() != "":

stable.toml renamed to dev.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Rename to build stable version
2-
# This is stable version
1+
# Rename to dev version
2+
# This is dev version
33
[build-system]
44
requires = ["setuptools>=61.0"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
8-
name = "automation_ide"
9-
version = "0.0.44"
8+
name = "automation_ide_dev"
9+
version = "0.0.52"
1010
authors = [
1111
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
1212
]
@@ -16,7 +16,7 @@ license-files = ["LICENSE"]
1616
dependencies = [
1717
"je-editor", "je_auto_control", "je_web_runner",
1818
"je_load_density", "je_api_testka", "je-mail-thunder",
19-
"automation-file", "PySide6==6.9.1", "test_pioneer"
19+
"automation-file", "PySide6==6.9.2", "test_pioneer"
2020
]
2121
classifiers = [
2222
"Programming Language :: Python :: 3.10",
@@ -35,5 +35,6 @@ Code = "https://github.com/Intergration-Automation-Testing/AutomationEditor"
3535
file = "README.md"
3636
content-type = "text/markdown"
3737

38+
3839
[tool.setuptools.packages]
3940
find = { namespaces = false }

dev_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ je-mail-thunder
88
automation_ide_dev
99
sphinx
1010
sphinx-rtd-theme
11-
PySide6==6.9.1
11+
PySide6==6.9.2
1212
auto-py-to-exe
1313
test_pioneer

pyproject.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Rename to dev version
2-
# This is dev version
1+
# Rename to build stable version
2+
# This is stable version
33
[build-system]
44
requires = ["setuptools>=61.0"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
8-
name = "automation_ide_dev"
9-
version = "0.0.49"
8+
name = "automation_ide"
9+
version = "0.0.46"
1010
authors = [
1111
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
1212
]
@@ -16,7 +16,7 @@ license-files = ["LICENSE"]
1616
dependencies = [
1717
"je-editor", "je_auto_control", "je_web_runner",
1818
"je_load_density", "je_api_testka", "je-mail-thunder",
19-
"automation-file", "PySide6==6.9.1", "test_pioneer"
19+
"automation-file", "PySide6==6.9.2", "test_pioneer"
2020
]
2121
classifiers = [
2222
"Programming Language :: Python :: 3.10",
@@ -35,6 +35,5 @@ Code = "https://github.com/Intergration-Automation-Testing/AutomationEditor"
3535
file = "README.md"
3636
content-type = "text/markdown"
3737

38-
3938
[tool.setuptools.packages]
4039
find = { namespaces = false }

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
automation_ide
2-
PySide6==6.9.1
2+
PySide6==6.9.2

0 commit comments

Comments
 (0)