-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from Integration-Automation/dev
Dev
- Loading branch information
Showing
21 changed files
with
302 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
103 changes: 103 additions & 0 deletions
103
...ation_editor/automation_editor_ui/menu/automation_file_menu/build_automation_file_menu.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import sys | ||
import webbrowser | ||
|
||
from PySide6.QtGui import QAction | ||
from PySide6.QtWidgets import QMainWindow | ||
|
||
from automation_editor.utils.test_executor.file_automation.file_automation_process import call_file_automation_test, \ | ||
call_file_automation_test_with_send, call_file_automation_test_multi_file, \ | ||
call_file_automation_test_multi_file_and_send | ||
|
||
|
||
def set_automation_file_menu(ui_we_want_to_set: QMainWindow): | ||
""" | ||
Build menu include WebRunner feature. | ||
:param ui_we_want_to_set: main window to add menu. | ||
:return: None | ||
""" | ||
ui_we_want_to_set.automation_file_menu = ui_we_want_to_set.menu.addMenu("FileAutomation") | ||
ui_we_want_to_set.automation_run_file_menu = ui_we_want_to_set.automation_file_menu.addMenu("Run") | ||
# Run FileAutomation Script | ||
ui_we_want_to_set.run_file_automation_action = QAction("Run FileAutomation Script") | ||
ui_we_want_to_set.run_file_automation_action.triggered.connect( | ||
lambda: call_file_automation_test( | ||
ui_we_want_to_set, | ||
ui_we_want_to_set.code_edit.toPlainText() | ||
) | ||
) | ||
ui_we_want_to_set.automation_run_file_menu.addAction(ui_we_want_to_set.run_file_automation_action) | ||
# Run FileAutomation Script With Send | ||
ui_we_want_to_set.run_file_automation_action_with_send = QAction("Run FileAutomation With Send") | ||
ui_we_want_to_set.run_file_automation_action_with_send.triggered.connect( | ||
lambda: call_file_automation_test_with_send( | ||
ui_we_want_to_set, | ||
ui_we_want_to_set.code_edit.toPlainText() | ||
) | ||
) | ||
ui_we_want_to_set.automation_run_file_menu.addAction( | ||
ui_we_want_to_set.run_file_automation_action_with_send | ||
) | ||
# Run Multi FileAutomation Script | ||
ui_we_want_to_set.run_multi_file_automation_action = QAction("Run Multi FileAutomation Script") | ||
ui_we_want_to_set.run_multi_file_automation_action.triggered.connect( | ||
lambda: call_file_automation_test_multi_file( | ||
ui_we_want_to_set, | ||
) | ||
) | ||
ui_we_want_to_set.automation_run_file_menu.addAction( | ||
ui_we_want_to_set.run_multi_file_automation_action | ||
) | ||
# Run Multi FileAutomation Script With Send | ||
ui_we_want_to_set.run_multi_file_automation_action_with_send = QAction("Run Multi FileAutomation Script With Send") | ||
ui_we_want_to_set.run_multi_file_automation_action_with_send.triggered.connect( | ||
lambda: call_file_automation_test_multi_file_and_send( | ||
ui_we_want_to_set, | ||
) | ||
) | ||
ui_we_want_to_set.automation_run_file_menu.addAction( | ||
ui_we_want_to_set.run_multi_file_automation_action_with_send | ||
) | ||
ui_we_want_to_set.file_automation_help_menu = ui_we_want_to_set.automation_file_menu.addMenu("HELP") | ||
# # Open Doc | ||
# ui_we_want_to_set.open_file_automation_doc_action = QAction("Open FileAutomation Doc") | ||
# ui_we_want_to_set.open_file_automation_doc_action.triggered.connect( | ||
# lambda: open_web_browser( | ||
# "https://webrunner.readthedocs.io/en/latest/" | ||
# ) | ||
# ) | ||
# ui_we_want_to_set.file_automation_help_menu.addAction( | ||
# ui_we_want_to_set.open_file_automation_doc_action | ||
# ) | ||
# Open Github | ||
ui_we_want_to_set.open_file_automation_github_action = QAction("Open FileAutomation GitHub") | ||
ui_we_want_to_set.open_file_automation_github_action.triggered.connect( | ||
lambda: open_web_browser( | ||
"https://github.com/Integration-Automation/FileAutomation" | ||
) | ||
) | ||
ui_we_want_to_set.file_automation_help_menu.addAction( | ||
ui_we_want_to_set.open_file_automation_github_action | ||
) | ||
ui_we_want_to_set.file_automation_project_menu = ui_we_want_to_set.automation_file_menu.addMenu("Project") | ||
# Create Project | ||
ui_we_want_to_set.create_web_runner_project_action = QAction("Create FileAutomation Project") | ||
ui_we_want_to_set.create_web_runner_project_action.triggered.connect( | ||
create_project | ||
) | ||
ui_we_want_to_set.file_automation_project_menu.addAction( | ||
ui_we_want_to_set.create_web_runner_project_action | ||
) | ||
|
||
|
||
def open_web_browser(url: str) -> None: | ||
webbrowser.open(url=url) | ||
|
||
|
||
def create_project() -> None: | ||
try: | ||
import file_automation | ||
package = file_automation | ||
if package is not None: | ||
package.create_project_dir() | ||
except ImportError as error: | ||
print(repr(error), file=sys.stderr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
105 changes: 105 additions & 0 deletions
105
automation_editor/utils/test_executor/file_automation/file_automation_process.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import json | ||
import sys | ||
|
||
from PySide6.QtWidgets import QMainWindow | ||
|
||
from automation_editor.extend.mail_thunder_extend.mail_thunder_setting import send_after_test | ||
from automation_editor.automation_editor_ui.show_code_window.code_window import CodeWindow | ||
from automation_editor.utils.exception.exception_tags import wrong_test_data_format_exception_tag | ||
from automation_editor.utils.exception.exceptions import ITETestExecutorException | ||
from automation_editor.utils.file_process.get_dir_file_list import ask_and_get_dir_files_as_list | ||
from automation_editor.utils.test_executor.check_mail_thunder import check_mail_thunder_install | ||
from automation_editor.utils.test_executor.task_process_manager import TaskProcessManager | ||
|
||
|
||
def call_file_automation_test( | ||
main_window: QMainWindow, | ||
test_format_code: str, | ||
program_buffer: int = 1024000 | ||
): | ||
try: | ||
code_window = CodeWindow() | ||
main_window.current_run_code_window.append(code_window) | ||
TaskProcessManager( | ||
main_window=code_window, | ||
program_buffer_size=program_buffer | ||
).start_test_process( | ||
"automation_file", | ||
exec_str=test_format_code, | ||
) | ||
except json.decoder.JSONDecodeError as error: | ||
print( | ||
repr(error) + | ||
"\n" | ||
+ wrong_test_data_format_exception_tag, | ||
file=sys.stderr | ||
) | ||
except ITETestExecutorException as error: | ||
print(repr(error), file=sys.stderr) | ||
|
||
|
||
def call_file_automation_test_with_send( | ||
main_window: QMainWindow, | ||
test_format_code: str, | ||
program_buffer: int = 1024000 | ||
): | ||
try: | ||
check_mail_thunder_install() | ||
code_window = CodeWindow() | ||
main_window.current_run_code_window.append(code_window) | ||
TaskProcessManager( | ||
main_window=code_window, | ||
task_done_trigger_function=send_after_test, | ||
program_buffer_size=program_buffer | ||
).start_test_process( | ||
"automation_file", | ||
exec_str=test_format_code, | ||
) | ||
except json.decoder.JSONDecodeError as error: | ||
print( | ||
repr(error) + | ||
"\n" | ||
+ wrong_test_data_format_exception_tag, | ||
file=sys.stderr | ||
) | ||
except ITETestExecutorException as error: | ||
print(repr(error), file=sys.stderr) | ||
|
||
|
||
def call_file_automation_test_multi_file( | ||
main_window: QMainWindow, | ||
program_buffer: int = 1024000 | ||
): | ||
try: | ||
need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window) | ||
if need_to_execute_list is not None \ | ||
and isinstance(need_to_execute_list, list) and len(need_to_execute_list) > 0: | ||
for execute_file in need_to_execute_list: | ||
with open(execute_file, "r+") as test_script_json: | ||
call_file_automation_test( | ||
main_window, | ||
test_script_json.read(), | ||
program_buffer | ||
) | ||
except Exception as error: | ||
print(repr(error), file=sys.stderr) | ||
|
||
|
||
def call_file_automation_test_multi_file_and_send( | ||
main_window: QMainWindow, | ||
program_buffer: int = 1024000 | ||
): | ||
try: | ||
check_mail_thunder_install() | ||
need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window) | ||
if need_to_execute_list is not None \ | ||
and isinstance(need_to_execute_list, list) and len(need_to_execute_list) > 0: | ||
for execute_file in need_to_execute_list: | ||
with open(execute_file, "r+") as test_script_json: | ||
call_file_automation_test_with_send( | ||
main_window, | ||
test_script_json.read(), | ||
program_buffer | ||
) | ||
except Exception as error: | ||
print(repr(error), file=sys.stderr) |
Oops, something went wrong.