Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions automation_ide/automation_editor_ui/editor_main/main_ui.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os
import sys
from pathlib import Path
from typing import List, Dict, Type

from PySide6.QtCore import QTimer, QCoreApplication
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QApplication, QWidget
from PySide6.QtWidgets import QApplication, QWidget, QSystemTrayIcon
from je_editor import EditorMain, language_wrapper
from je_editor.pyside_ui.main_ui.system_tray.extend_system_tray import ExtendSystemTray
from qt_material import apply_stylesheet

from automation_ide.automation_editor_ui.extend_multi_language.update_language_dict import update_language_dict
Expand Down Expand Up @@ -39,8 +41,10 @@ def __init__(self, debug_mode: bool = False, show_system_tray_ray: bool = False)
for widget_name, widget in EDITOR_EXTEND_TAB.items():
self.tab_widget.addTab(widget(), widget_name)
# Icon
self.icon_path = Path(str(Path.cwd()) + "/je_driver_icon.ico")
self.icon_path = Path(os.getcwd() + "/je_driver_icon.ico")
self.icon = QIcon(str(self.icon_path))
self.system_tray = QSystemTrayIcon()
self.system_tray.setIcon(self.icon)
# Title
self.setWindowTitle(language_wrapper.language_word_dict.get("automation_editor_application_name"))
if debug_mode:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ def update_english_word_dict():
"test_pioneer_label": "TestPioneer",
"test_pioneer_create_template_label": "Create TestPioneer Yaml template",
"test_pioneer_run_yaml": "Execute Test Pioneer Yaml",
"test_pioneer_not_choose_yaml": "Please choose a Yaml file",
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ def update_traditional_chinese_word_dict():
"test_pioneer_label": "TestPioneer",
"test_pioneer_create_template_label": "建立 TestPioneer Yaml 模板",
"test_pioneer_run_yaml": "執行 Test Pioneer Yaml",
"test_pioneer_not_choose_yaml": "請選擇 Yaml 檔案",
}
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING

from PySide6.QtWidgets import QFileDialog, QMessageBox

from automation_ide.extend.process_executor.test_pioneer.test_pioneer_process_manager import init_and_start_test_pioneer_process

if TYPE_CHECKING:
Expand Down Expand Up @@ -33,8 +36,26 @@ def set_test_pioneer_menu(ui_we_want_to_set: AutomationEditor):
ui_we_want_to_set.run_yaml_action = QAction(
language_wrapper.language_word_dict.get("test_pioneer_run_yaml"))
ui_we_want_to_set.run_yaml_action.triggered.connect(
lambda: init_and_start_test_pioneer_process(ui_we_want_to_set)
lambda: check_file(ui_we_want_to_set)
)
ui_we_want_to_set.test_pioneer_menu.addAction(
ui_we_want_to_set.run_yaml_action
)


def check_file(ui_we_want_to_set: AutomationEditor):
dialog = QFileDialog(ui_we_want_to_set)
dialog.setNameFilter("Yaml (*.yml)")
file_tuple = dialog.getOpenFileName()
show_messagebox = False
if file_tuple:
file_path = file_tuple[0]
if Path(file_path).is_file() and Path(file_path).suffix == ".yml":
init_and_start_test_pioneer_process(ui_we_want_to_set, file_path)
else:
show_messagebox = True
if show_messagebox:
messagebox = QMessageBox(ui_we_want_to_set)
messagebox.setWindowTitle(language_wrapper.language_word_dict.get("test_pioneer_not_choose_yaml"))
messagebox.setText(language_wrapper.language_word_dict.get("test_pioneer_not_choose_yaml"))
messagebox.exec_()
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import threading
from pathlib import Path
from queue import Queue
from typing import Union, TYPE_CHECKING
from typing import TYPE_CHECKING

from PySide6.QtCore import QTimer
from PySide6.QtWidgets import QWidget
from je_editor import EditorWidget
from PySide6.QtWidgets import QWidget, QFileDialog, QMessageBox
from frontengine import language_wrapper
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

Expand All @@ -25,7 +25,7 @@ class TestPioneerProcess(object):
def __init__(
self,
main_window: AutomationEditor,
exec_str: Union[str, None] = None,
executable_path: str,
program_buffer: int = 1024000,
encoding: str = "utf-8",
):
Expand All @@ -42,10 +42,6 @@ def __init__(
self._read_program_error_output_from_thread: [threading.Thread, None] = None
self._read_program_output_from_thread: [threading.Thread, None] = None
self._timer: QTimer = QTimer(self._code_window)
if isinstance(self._widget, EditorWidget) and exec_str is None:
self._test_format_code = self._widget.code_edit.toPlainText()
else:
self._test_format_code = exec_str
if self._main_window.python_compiler is None:
# Renew compiler path
if sys.platform in ["win32", "cygwin", "msys"]:
Expand All @@ -61,10 +57,12 @@ def __init__(
"-m",
"test_pioneer",
"-e",
self._test_format_code
executable_path
]
else:
args = " ".join([f"{self._compiler_path}", "-m test_pioneer", "-e", f"{self._test_format_code}"])
args = " ".join([
f"{self._compiler_path}", "-m test_pioneer", "-e", f"{executable_path}"
])
self._process: subprocess.Popen = subprocess.Popen(
args,
stdin=subprocess.PIPE,
Expand Down Expand Up @@ -166,6 +164,9 @@ def start_test_pioneer_process(self):
self._timer.start()


def init_and_start_test_pioneer_process(ui_we_want_to_set: AutomationEditor):
test_pioneer_process_manager = TestPioneerProcess(main_window=ui_we_want_to_set)
test_pioneer_process_manager.start_test_pioneer_process()
def init_and_start_test_pioneer_process(ui_we_want_to_set: AutomationEditor, file_path: str):
test_pioneer_process_manager = TestPioneerProcess(
main_window=ui_we_want_to_set, executable_path=file_path)
test_pioneer_process_manager.start_test_pioneer_process()