From 3c8515b7ba238599de59f8b8e4b9bf49356df992 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Thu, 7 Apr 2022 19:09:53 +0800 Subject: [PATCH 1/2] update dev version update dev version --- .circleci/config.yml | 6 +++ .idea/workspace.xml | 52 ++++++++++++------- dev_setup.py | 2 +- je_auto_control/__init__.py | 9 +++- .../utils/executor/action_executor.py | 10 ++++ .../utils/file_process/__init__.py | 0 .../utils/file_process/get_dir_file_list.py | 18 +++++++ .../get_dir_file_and_execute.py | 8 +++ .../get_dir_file_and_execute/test1.json | 1 + .../get_dir_file_and_execute/test2.json | 1 + .../get_dir_file_and_execute/test3.json | 1 + 11 files changed, 87 insertions(+), 21 deletions(-) create mode 100644 je_auto_control/utils/file_process/__init__.py create mode 100644 je_auto_control/utils/file_process/get_dir_file_list.py create mode 100644 test/integrated_test/get_dir_file_and_execute/get_dir_file_and_execute.py create mode 100644 test/integrated_test/get_dir_file_and_execute/test1.json create mode 100644 test/integrated_test/get_dir_file_and_execute/test2.json create mode 100644 test/integrated_test/get_dir_file_and_execute/test3.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 4909108..d7ebea9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -97,6 +97,9 @@ jobs: - run: command: python ./test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py name: total_record_and_html_report_test + - run: + command: python ./test/integrated_test/get_dir_file_and_execute/get_dir_file_and_execute.py + name: get_dir_file_and_execute build-and-test-windows-stable: executor: @@ -190,6 +193,9 @@ jobs: - run: command: python ./test/integrated_test/total_record_and_html_report_test/total_record_and_html_report_test.py name: total_record_and_html_report_test + - run: + command: python ./test/integrated_test/get_dir_file_and_execute/get_dir_file_and_execute.py + name: get_dir_file_and_execute workflows: main: diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5f8c2cc..477a2f2 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,19 @@ - + + + + + + + + + + + + + - + + - @@ -71,7 +83,7 @@ - + - + - + @@ -352,6 +364,9 @@ + + + @@ -394,6 +409,7 @@ + diff --git a/dev_setup.py b/dev_setup.py index 0e209b9..027b2e7 100644 --- a/dev_setup.py +++ b/dev_setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control_dev", - version="0.0.15", + version="0.0.16", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing", diff --git a/je_auto_control/__init__.py b/je_auto_control/__init__.py index cb2cd02..74f32bc 100644 --- a/je_auto_control/__init__.py +++ b/je_auto_control/__init__.py @@ -50,10 +50,13 @@ from je_auto_control.wrapper.auto_control_record import stop_record # json -from je_auto_control.utils.executor.action_executor import execute_action from je_auto_control.utils.json.json_file import read_action_json from je_auto_control.utils.json.json_file import write_action_json +# executor +from je_auto_control.utils.executor.action_executor import execute_action +from je_auto_control.utils.executor.action_executor import execute_files + # timeout from je_auto_control.utils.timeout.multiprocess_timeout import multiprocess_timeout # test record @@ -63,5 +66,7 @@ from je_auto_control.wrapper.auto_control_image import screenshot # html report - from je_auto_control.utils.html_report.html_report_generate import generate_html + +# file process +from je_auto_control.utils.file_process.get_dir_file_list import get_dir_files_as_list diff --git a/je_auto_control/utils/executor/action_executor.py b/je_auto_control/utils/executor/action_executor.py index 6fd2e82..7295433 100644 --- a/je_auto_control/utils/executor/action_executor.py +++ b/je_auto_control/utils/executor/action_executor.py @@ -23,6 +23,7 @@ from je_auto_control.utils.exception.exception_tag import action_is_null_error from je_auto_control.utils.exception.exception_tag import cant_execute_action_error from je_auto_control.utils.exception.exceptions import AutoControlActionException +from je_auto_control.utils.json.json_file import read_action_json from je_auto_control.utils.test_record.record_test_class import record_total @@ -86,3 +87,12 @@ def execute_action(action_list: list): except Exception as error: print(repr(error), file=sys.stderr) return execute_record_string + + +def execute_files(execute_files_list: list): + """ + :param execute_files_list: + :return: + """ + for file in execute_files_list: + execute_action(read_action_json(file)) diff --git a/je_auto_control/utils/file_process/__init__.py b/je_auto_control/utils/file_process/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/je_auto_control/utils/file_process/get_dir_file_list.py b/je_auto_control/utils/file_process/get_dir_file_list.py new file mode 100644 index 0000000..0681ac2 --- /dev/null +++ b/je_auto_control/utils/file_process/get_dir_file_list.py @@ -0,0 +1,18 @@ +from os import walk +from os import getcwd +from os.path import abspath +from os.path import join + + +def get_dir_files_as_list(dir_path: str = getcwd(), default_search_file_extension: str = ".json"): + """ + :param dir_path: which dir we want to walk and get file list + :param default_search_file_extension: which extension we want to search + :return: [] if nothing searched or [file1, file2.... files] file was searched + """ + return [ + abspath(join(dir_path, file)) for root, dirs, files in walk(dir_path) + for file in files + if file.endswith(default_search_file_extension.lower()) + ] + diff --git a/test/integrated_test/get_dir_file_and_execute/get_dir_file_and_execute.py b/test/integrated_test/get_dir_file_and_execute/get_dir_file_and_execute.py new file mode 100644 index 0000000..bb3d5a6 --- /dev/null +++ b/test/integrated_test/get_dir_file_and_execute/get_dir_file_and_execute.py @@ -0,0 +1,8 @@ +import os + +from je_auto_control import get_dir_files_as_list +from je_auto_control import execute_files +files_list = get_dir_files_as_list(os.getcwd() + "/test/integrated_test/get_dir_file_and_execute") +print(files_list) +if files_list is not None: + execute_files(files_list) diff --git a/test/integrated_test/get_dir_file_and_execute/test1.json b/test/integrated_test/get_dir_file_and_execute/test1.json new file mode 100644 index 0000000..a8d8b9f --- /dev/null +++ b/test/integrated_test/get_dir_file_and_execute/test1.json @@ -0,0 +1 @@ +[["type_key", {"keycode": 0}], ["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}], ["position"], ["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}], ["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}]] \ No newline at end of file diff --git a/test/integrated_test/get_dir_file_and_execute/test2.json b/test/integrated_test/get_dir_file_and_execute/test2.json new file mode 100644 index 0000000..a8d8b9f --- /dev/null +++ b/test/integrated_test/get_dir_file_and_execute/test2.json @@ -0,0 +1 @@ +[["type_key", {"keycode": 0}], ["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}], ["position"], ["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}], ["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}]] \ No newline at end of file diff --git a/test/integrated_test/get_dir_file_and_execute/test3.json b/test/integrated_test/get_dir_file_and_execute/test3.json new file mode 100644 index 0000000..a8d8b9f --- /dev/null +++ b/test/integrated_test/get_dir_file_and_execute/test3.json @@ -0,0 +1 @@ +[["type_key", {"keycode": 0}], ["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}], ["position"], ["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}], ["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}]] \ No newline at end of file From 88220bdb67dbd0b1d158dcfdb86e891b243cc724 Mon Sep 17 00:00:00 2001 From: JE-Chen Date: Thu, 7 Apr 2022 20:27:44 +0800 Subject: [PATCH 2/2] update stable version update stable version --- .idea/workspace.xml | 13 ++----------- setup.py | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 477a2f2..2ec4d7c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,17 +2,8 @@ - - - - - - - - - - + diff --git a/setup.py b/setup.py index 0326089..fe2d39c 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control", - version="0.0.85", + version="0.0.86", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing",