Skip to content

Commit f44bbcf

Browse files
authored
Merge pull request #85 from Integration-Automation/dev
Edit test pioneer menu and action
2 parents 2715853 + ba336be commit f44bbcf

5 files changed

Lines changed: 44 additions & 16 deletions

File tree

automation_ide/automation_editor_ui/editor_main/main_ui.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import os
12
import sys
23
from pathlib import Path
34
from typing import List, Dict, Type
45

56
from PySide6.QtCore import QTimer, QCoreApplication
67
from PySide6.QtGui import QIcon
7-
from PySide6.QtWidgets import QApplication, QWidget
8+
from PySide6.QtWidgets import QApplication, QWidget, QSystemTrayIcon
89
from je_editor import EditorMain, language_wrapper
10+
from je_editor.pyside_ui.main_ui.system_tray.extend_system_tray import ExtendSystemTray
911
from qt_material import apply_stylesheet
1012

1113
from automation_ide.automation_editor_ui.extend_multi_language.update_language_dict import update_language_dict
@@ -39,8 +41,10 @@ def __init__(self, debug_mode: bool = False, show_system_tray_ray: bool = False)
3941
for widget_name, widget in EDITOR_EXTEND_TAB.items():
4042
self.tab_widget.addTab(widget(), widget_name)
4143
# Icon
42-
self.icon_path = Path(str(Path.cwd()) + "/je_driver_icon.ico")
44+
self.icon_path = Path(os.getcwd() + "/je_driver_icon.ico")
4345
self.icon = QIcon(str(self.icon_path))
46+
self.system_tray = QSystemTrayIcon()
47+
self.system_tray.setIcon(self.icon)
4448
# Title
4549
self.setWindowTitle(language_wrapper.language_word_dict.get("automation_editor_application_name"))
4650
if debug_mode:

automation_ide/automation_editor_ui/extend_multi_language/extend_english.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,6 @@ def update_english_word_dict():
9898
"test_pioneer_label": "TestPioneer",
9999
"test_pioneer_create_template_label": "Create TestPioneer Yaml template",
100100
"test_pioneer_run_yaml": "Execute Test Pioneer Yaml",
101+
"test_pioneer_not_choose_yaml": "Please choose a Yaml file",
101102
}
102103
)

automation_ide/automation_editor_ui/extend_multi_language/extend_traditional_chinese.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,6 @@ def update_traditional_chinese_word_dict():
9898
"test_pioneer_label": "TestPioneer",
9999
"test_pioneer_create_template_label": "建立 TestPioneer Yaml 模板",
100100
"test_pioneer_run_yaml": "執行 Test Pioneer Yaml",
101+
"test_pioneer_not_choose_yaml": "請選擇 Yaml 檔案",
101102
}
102103
)

automation_ide/automation_editor_ui/menu/automation_menu/test_pioneer_menu/build_test_pioneer_menu.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from __future__ import annotations
22

3+
from pathlib import Path
34
from typing import TYPE_CHECKING
45

6+
from PySide6.QtWidgets import QFileDialog, QMessageBox
7+
58
from automation_ide.extend.process_executor.test_pioneer.test_pioneer_process_manager import init_and_start_test_pioneer_process
69

710
if TYPE_CHECKING:
@@ -33,8 +36,26 @@ def set_test_pioneer_menu(ui_we_want_to_set: AutomationEditor):
3336
ui_we_want_to_set.run_yaml_action = QAction(
3437
language_wrapper.language_word_dict.get("test_pioneer_run_yaml"))
3538
ui_we_want_to_set.run_yaml_action.triggered.connect(
36-
lambda: init_and_start_test_pioneer_process(ui_we_want_to_set)
39+
lambda: check_file(ui_we_want_to_set)
3740
)
3841
ui_we_want_to_set.test_pioneer_menu.addAction(
3942
ui_we_want_to_set.run_yaml_action
4043
)
44+
45+
46+
def check_file(ui_we_want_to_set: AutomationEditor):
47+
dialog = QFileDialog(ui_we_want_to_set)
48+
dialog.setNameFilter("Yaml (*.yml)")
49+
file_tuple = dialog.getOpenFileName()
50+
show_messagebox = False
51+
if file_tuple:
52+
file_path = file_tuple[0]
53+
if Path(file_path).is_file() and Path(file_path).suffix == ".yml":
54+
init_and_start_test_pioneer_process(ui_we_want_to_set, file_path)
55+
else:
56+
show_messagebox = True
57+
if show_messagebox:
58+
messagebox = QMessageBox(ui_we_want_to_set)
59+
messagebox.setWindowTitle(language_wrapper.language_word_dict.get("test_pioneer_not_choose_yaml"))
60+
messagebox.setText(language_wrapper.language_word_dict.get("test_pioneer_not_choose_yaml"))
61+
messagebox.exec_()

automation_ide/extend/process_executor/test_pioneer/test_pioneer_process_manager.py

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

1111
from PySide6.QtCore import QTimer
12-
from PySide6.QtWidgets import QWidget
13-
from je_editor import EditorWidget
12+
from PySide6.QtWidgets import QWidget, QFileDialog, QMessageBox
13+
from frontengine import language_wrapper
1414
from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict
1515
from je_editor.utils.venv_check.check_venv import check_and_choose_venv
1616

@@ -25,7 +25,7 @@ class TestPioneerProcess(object):
2525
def __init__(
2626
self,
2727
main_window: AutomationEditor,
28-
exec_str: Union[str, None] = None,
28+
executable_path: str,
2929
program_buffer: int = 1024000,
3030
encoding: str = "utf-8",
3131
):
@@ -42,10 +42,6 @@ def __init__(
4242
self._read_program_error_output_from_thread: [threading.Thread, None] = None
4343
self._read_program_output_from_thread: [threading.Thread, None] = None
4444
self._timer: QTimer = QTimer(self._code_window)
45-
if isinstance(self._widget, EditorWidget) and exec_str is None:
46-
self._test_format_code = self._widget.code_edit.toPlainText()
47-
else:
48-
self._test_format_code = exec_str
4945
if self._main_window.python_compiler is None:
5046
# Renew compiler path
5147
if sys.platform in ["win32", "cygwin", "msys"]:
@@ -61,10 +57,12 @@ def __init__(
6157
"-m",
6258
"test_pioneer",
6359
"-e",
64-
self._test_format_code
60+
executable_path
6561
]
6662
else:
67-
args = " ".join([f"{self._compiler_path}", "-m test_pioneer", "-e", f"{self._test_format_code}"])
63+
args = " ".join([
64+
f"{self._compiler_path}", "-m test_pioneer", "-e", f"{executable_path}"
65+
])
6866
self._process: subprocess.Popen = subprocess.Popen(
6967
args,
7068
stdin=subprocess.PIPE,
@@ -166,6 +164,9 @@ def start_test_pioneer_process(self):
166164
self._timer.start()
167165

168166

169-
def init_and_start_test_pioneer_process(ui_we_want_to_set: AutomationEditor):
170-
test_pioneer_process_manager = TestPioneerProcess(main_window=ui_we_want_to_set)
171-
test_pioneer_process_manager.start_test_pioneer_process()
167+
def init_and_start_test_pioneer_process(ui_we_want_to_set: AutomationEditor, file_path: str):
168+
test_pioneer_process_manager = TestPioneerProcess(
169+
main_window=ui_we_want_to_set, executable_path=file_path)
170+
test_pioneer_process_manager.start_test_pioneer_process()
171+
172+

0 commit comments

Comments
 (0)