Skip to content

Commit 1170b0a

Browse files
committed
Refactor
1 parent 0a0bd1d commit 1170b0a

File tree

11 files changed

+64
-79
lines changed

11 files changed

+64
-79
lines changed

.idea/workspace.xml

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

autocontrol_driver/generate_autocontrol_driver.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
from je_auto_control import start_autocontrol_socket_server
44

5-
try:
6-
server = start_autocontrol_socket_server()
7-
while not server.close_flag:
8-
pass
9-
sys.exit(0)
10-
except Exception as error:
11-
print(repr(error))
5+
server = start_autocontrol_socket_server()
6+
while True:
7+
if server.close_flag:
8+
sys.exit(0)

je_auto_control/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@
104104
# import screen
105105
from je_auto_control.wrapper.auto_control_screen import screen_size
106106
from je_auto_control.wrapper.auto_control_screen import screenshot
107-
# GUI
108-
from je_auto_control.gui.main_window import start_autocontrol_gui
109107
__all__ = [
110108
"click_mouse", "mouse_keys_table", "get_mouse_position", "press_mouse", "release_mouse",
111109
"mouse_scroll", "set_mouse_position", "special_mouse_keys_table",
@@ -121,5 +119,4 @@
121119
"generate_html", "generate_html_report", "generate_json", "generate_json_report", "generate_xml",
122120
"generate_xml_report", "get_dir_files_as_list", "create_project_dir", "start_autocontrol_socket_server",
123121
"callback_executor", "package_manager", "get_special_table", "ShellManager", "default_shell_manager",
124-
"start_autocontrol_gui"
125122
]

je_auto_control/utils/callback/callback_function_executor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ def callback_function(
128128
**kwargs
129129
) -> Any:
130130
"""
131-
:param trigger_function_name: what function we want to trigger only accept function in event_dict
132-
:param callback_function: what function we want to callback
133-
:param callback_function_param: callback function's param only accept dict
134-
:param callback_param_method: what type param will use on callback function only accept kwargs and args
135-
:param kwargs: trigger_function's param
136-
:return: trigger_function_name return value
131+
:param trigger_function_name: what function we want to trigger only accept function in event_dict.
132+
:param callback_function: what function we want to callback.
133+
:param callback_function_param: callback function's param only accept dict.
134+
:param callback_param_method: what type param will use on callback function only accept kwargs and args.
135+
:param kwargs: trigger_function's param.
136+
:return: trigger_function_name return value.
137137
"""
138138
try:
139139
if trigger_function_name not in self.event_dict.keys():

je_auto_control/utils/cv2_utils/template_detection.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
def find_image(image, detect_threshold: float = 1, draw_image: bool = False) -> List[int]:
88
"""
9-
:param image which cv2_utils we want to find on screen
10-
:param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal
11-
:param draw_image draw detect tag on return cv2_utils
9+
Find image with detect threshold on screen.
10+
:param image: which cv2_utils we want to find on screen
11+
:param detect_threshold: detect precision 0.0 ~ 1.0; 1 is absolute equal
12+
:param draw_image: draw detect tag on return cv2_utils
1213
"""
1314
grab_image = ImageGrab.grab()
1415
return template_detection.find_object(image=grab_image, template=image,
@@ -17,9 +18,10 @@ def find_image(image, detect_threshold: float = 1, draw_image: bool = False) ->
1718

1819
def find_image_multi(image, detect_threshold: float = 1, draw_image: bool = False) -> List[List[int]]:
1920
"""
20-
:param image which cv2_utils we want to find on screen
21-
:param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal
22-
:param draw_image draw detect tag on return cv2_utils
21+
Find multi image with detect threshold on screen.
22+
:param image: which cv2_utils we want to find on screen
23+
:param detect_threshold: detect precision 0.0 ~ 1.0; 1 is absolute equal
24+
:param draw_image: draw detect tag on return cv2_utils
2325
"""
2426
grab_image = ImageGrab.grab()
2527
return template_detection.find_multi_object(image=grab_image, template=image,

je_auto_control/utils/exception/exceptions.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,101 +4,97 @@ class AutoControlException(Exception):
44

55

66
# Keyboard
7-
8-
9-
class AutoControlKeyboardException(AutoControlException):
7+
class AutoControlKeyboardException(Exception):
108
pass
119

1210

13-
class AutoControlCantFindKeyException(AutoControlKeyboardException):
11+
class AutoControlCantFindKeyException(Exception):
1412
pass
1513

1614

1715
# Mouse
18-
19-
20-
class AutoControlMouseException(AutoControlException):
16+
class AutoControlMouseException(Exception):
2117
pass
2218

2319

2420
# Screen
2521

2622

27-
class AutoControlScreenException(AutoControlException):
23+
class AutoControlScreenException(Exception):
2824
pass
2925

3026

3127
# Image detect
3228

3329

34-
class ImageNotFoundException(AutoControlException):
30+
class ImageNotFoundException(Exception):
3531
pass
3632

3733

3834
# Record
3935

4036

41-
class AutoControlRecordException(AutoControlException):
37+
class AutoControlRecordException(Exception):
4238
pass
4339

4440

4541
# Execute action
4642

47-
class AutoControlExecuteActionException(AutoControlException):
43+
class AutoControlExecuteActionException(Exception):
4844
pass
4945

5046

51-
class AutoControlJsonActionException(AutoControlExecuteActionException):
47+
class AutoControlJsonActionException(Exception):
5248
pass
5349

5450

55-
class AutoControlActionNullException(AutoControlExecuteActionException):
51+
class AutoControlActionNullException(Exception):
5652
pass
5753

5854

59-
class AutoControlActionException(AutoControlExecuteActionException):
55+
class AutoControlActionException(Exception):
6056
pass
6157

6258

63-
class AutoControlAddCommandException(AutoControlExecuteActionException):
59+
class AutoControlAddCommandException(Exception):
6460
pass
6561

6662

67-
class AutoControlArgparseException(AutoControlExecuteActionException):
63+
class AutoControlArgparseException(Exception):
6864
pass
6965

7066

7167
# timeout
72-
class AutoControlTimeoutException(AutoControlException):
68+
class AutoControlTimeoutException(Exception):
7369
pass
7470

7571

7672
# html exception
7773

78-
class AutoControlHTMLException(AutoControlException):
74+
class AutoControlHTMLException(Exception):
7975
pass
8076

8177

8278
# Json Exception
8379

84-
class AutoControlJsonException(AutoControlException):
80+
class AutoControlJsonException(Exception):
8581
pass
8682

8783

88-
class AutoControlGenerateJsonReportException(AutoControlJsonException):
84+
class AutoControlGenerateJsonReportException(Exception):
8985
pass
9086

9187

9288
# XML
9389

94-
class XMLException(AutoControlException):
90+
class XMLException(Exception):
9591
pass
9692

9793

98-
class XMLTypeException(XMLException):
94+
class XMLTypeException(Exception):
9995
pass
10096

10197

10298
# Execute callback
103-
class CallbackExecutorException(AutoControlException):
99+
class CallbackExecutorException(Exception):
104100
pass

je_auto_control/utils/executor/action_executor.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,12 @@ def execute_action(self, action_list: [list, dict]) -> Dict[str, str]:
124124
"""
125125
auto_control_logger.info(f"execute_action, action_list: {action_list}")
126126
if isinstance(action_list, dict):
127-
action_list: list = action_list.get("auto_control", None)
127+
action_list: list = action_list.get("auto_control")
128128
if action_list is None:
129129
raise AutoControlActionNullException(executor_list_error)
130130
execute_record_dict = dict()
131131
try:
132-
if len(action_list) > 0 or isinstance(action_list, list):
133-
pass
134-
else:
132+
if len(action_list) < 0 or isinstance(action_list, list) is False:
135133
raise AutoControlActionNullException(action_is_null_error)
136134
except Exception as error:
137135
record_action_to_list("AC_execute_action", action_list, repr(error))
@@ -167,14 +165,14 @@ def execute_files(self, execute_files_list: list) -> List[Dict[str, str]]:
167165
return execute_detail_list
168166

169167
def scheduler_event_trigger(
170-
self, function: str, id: str = None, args: Union[list, tuple] = None,
168+
self, function: str, scheduler_id: str = None, args: Union[list, tuple] = None,
171169
kwargs: dict = None, scheduler_type: str = "nonblocking", wait_type: str = "secondly",
172170
wait_value: int = 1, **trigger_args: Any) -> None:
173171
if scheduler_type == "nonblocking":
174172
scheduler_event = scheduler_manager.nonblocking_scheduler_event_dict.get(wait_type)
175173
else:
176174
scheduler_event = scheduler_manager.blocking_scheduler_event_dict.get(wait_type)
177-
scheduler_event(self.event_dict.get(function), id, args, kwargs, wait_value, **trigger_args)
175+
scheduler_event(self.event_dict.get(function), scheduler_id, args, kwargs, wait_value, **trigger_args)
178176

179177

180178
executor = Executor()

je_auto_control/utils/scheduler/extend_apscheduler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def add_blocking_job(
5858
"""
5959
params = locals()
6060
params.pop("self")
61-
trigger_args = params.pop("trigger_args")
61+
params.pop("trigger_args")
6262
return self._blocking_schedulers.add_job(**params, **trigger_args)
6363

6464
def add_nonblocking_job(
@@ -92,7 +92,7 @@ def add_nonblocking_job(
9292
"""
9393
params = locals()
9494
params.pop("self")
95-
trigger_args = params.pop("trigger_args")
95+
params.pop("trigger_args")
9696
return self._background_schedulers.add_job(**params, **trigger_args)
9797

9898
def get_blocking_scheduler(self) -> BlockingScheduler:

je_auto_control/utils/xml/change_xml_structure/change_xml_structure.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def dict_to_elements_tree(json_dict: dict):
3535
"""
3636

3737
def _to_elements_tree(json_dict: dict, root):
38-
if not json_dict:
39-
pass
40-
elif isinstance(json_dict, str):
38+
if isinstance(json_dict, str):
4139
root.text = json_dict
4240
elif isinstance(json_dict, dict):
4341
for key, value in json_dict.items():

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66

77
[project]
88
name = "je_auto_control_dev"
9-
version = "0.0.99"
9+
version = "0.0.100"
1010
authors = [
1111
{ name = "JE-Chen", email = "[email protected]" },
1212
]
@@ -20,8 +20,6 @@ dependencies = [
2020
"pyobjc-core;platform_system=='Darwin'",
2121
"pyobjc;platform_system=='Darwin'",
2222
"python-Xlib;platform_system=='Linux'",
23-
"Pyside6",
24-
"qt-material"
2523
]
2624
classifiers = [
2725
"Programming Language :: Python :: 3.9",

0 commit comments

Comments
 (0)