Skip to content

Commit 50f4165

Browse files
authored
Merge pull request #44 from JE-Chen/dev
Dev
2 parents 846a6b0 + cdf138e commit 50f4165

File tree

9 files changed

+49
-45
lines changed

9 files changed

+49
-45
lines changed

.idea/Python_JEAutoControl.iml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 17 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="je_auto_control_dev",
8-
version="0.0.25",
8+
version="0.0.26",
99
author="JE-Chen",
1010
author_email="zenmailman@gmail.com",
1111
description="auto testing",

je_auto_control/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
from je_auto_control.utils.executor.action_executor import execute_action
5858
from je_auto_control.utils.executor.action_executor import execute_files
5959
from je_auto_control.utils.executor.action_executor import executor
60+
from je_auto_control.utils.executor.action_executor import add_command_to_executor
6061

6162
# timeout
6263
from je_auto_control.utils.timeout.multiprocess_timeout import multiprocess_timeout

je_auto_control/utils/exception/exception_tag.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@
4646
timeout_need_on_main_error = "should put timeout function on main"
4747
# HTML
4848
html_generate_no_data_tag = "record is None"
49+
# add command
50+
add_command_exception_tag = "command value type should be as method or function"

je_auto_control/utils/exception/exceptions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ class AutoControlTimeoutException(AutoControlException):
6464

6565
# html exception
6666

67-
class HTMLException(AutoControlException):
67+
class AutoControlHTMLException(AutoControlException):
68+
pass
69+
70+
71+
class AutoControlAddCommandException(AutoControlException):
6872
pass
6973

7074

je_auto_control/utils/executor/action_executor.py

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,18 @@
11
import sys
2+
import types
23

3-
from je_auto_control import AutoControlActionNullException
4-
from je_auto_control import check_key_is_press
5-
from je_auto_control import click_mouse
6-
from je_auto_control import hotkey
7-
from je_auto_control import keys_table
8-
from je_auto_control import locate_all_image
9-
from je_auto_control import locate_and_click
10-
from je_auto_control import locate_image_center
11-
from je_auto_control import mouse_table
12-
from je_auto_control import position
13-
from je_auto_control import press_key
14-
from je_auto_control import press_mouse
15-
from je_auto_control import release_key
16-
from je_auto_control import release_mouse
17-
from je_auto_control import screenshot
18-
from je_auto_control import scroll
4+
from je_auto_control import keys_table, press_key, release_key, hotkey, type_key, write
5+
from je_auto_control import locate_all_image, locate_and_click, locate_image_center
6+
from je_auto_control import mouse_table, check_key_is_press, position, press_mouse, release_mouse, click_mouse, scroll
197
from je_auto_control import set_position
20-
from je_auto_control import size
21-
from je_auto_control import special_table
22-
from je_auto_control import type_key
23-
from je_auto_control import write
24-
from je_auto_control.utils.exception.exception_tag import action_is_null_error
8+
from je_auto_control import screenshot, size, special_table
9+
from je_auto_control.utils.exception.exception_tag import action_is_null_error, add_command_exception_tag
2510
from je_auto_control.utils.exception.exception_tag import cant_execute_action_error
26-
from je_auto_control.utils.exception.exceptions import AutoControlActionException
11+
from je_auto_control.utils.exception.exceptions import AutoControlActionException, AutoControlAddCommandException
12+
from je_auto_control.utils.exception.exceptions import AutoControlActionNullException
2713
from je_auto_control.utils.html_report.html_report_generate import generate_html
2814
from je_auto_control.utils.json.json_file import read_action_json
29-
from je_auto_control.utils.test_record.record_test_class import record_action_to_list
30-
from je_auto_control.utils.test_record.record_test_class import test_record_instance
15+
from je_auto_control.utils.test_record.record_test_class import record_action_to_list, test_record_instance
3116

3217

3318
class Executor(object):
@@ -113,6 +98,14 @@ def execute_files(self, execute_files_list: list) -> list:
11398
executor = Executor()
11499

115100

101+
def add_command_to_executor(command_dict: dict):
102+
for command_name, command in command_dict.items():
103+
if isinstance(command, (types.MethodType, types.FunctionType)):
104+
executor.event_dict.update({command_name: command})
105+
else:
106+
raise AutoControlAddCommandException(add_command_exception_tag)
107+
108+
116109
def execute_action(action_list: list) -> str:
117110
return executor.execute_action(action_list)
118111

je_auto_control/utils/html_report/html_report_generate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22

33
from je_auto_control.utils.test_record.record_test_class import test_record_instance
4-
from je_auto_control.utils.exception.exceptions import HTMLException
4+
from je_auto_control.utils.exception.exceptions import AutoControlHTMLException
55
from je_auto_control.utils.exception.exception_tag import html_generate_no_data_tag
66
from threading import Lock
77

@@ -135,7 +135,7 @@ def generate_html(html_name: str = "default_name") -> str:
135135
:return: html_string
136136
"""
137137
if len(test_record_instance.test_record_list) == 0:
138-
raise HTMLException(html_generate_no_data_tag)
138+
raise AutoControlHTMLException(html_generate_no_data_tag)
139139
else:
140140
event_str = ""
141141
for record_data in test_record_instance.test_record_list:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="je_auto_control",
8-
version="0.0.92",
8+
version="0.0.93",
99
author="JE-Chen",
1010
author_email="zenmailman@gmail.com",
1111
description="auto testing",

0 commit comments

Comments
 (0)