Skip to content

Commit 0504184

Browse files
authored
Merge pull request #30 from JE-Chen/dev
Dev
2 parents 56abe02 + 176c634 commit 0504184

File tree

8 files changed

+69
-48
lines changed

8 files changed

+69
-48
lines changed

.idea/workspace.xml

Lines changed: 22 additions & 28 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.16",
8+
version="0.0.17",
99
author="JE-Chen",
1010
author_email="[email protected]",
1111
description="auto testing",

je_auto_control/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@
7070

7171
# file process
7272
from je_auto_control.utils.file_process.get_dir_file_list import get_dir_files_as_list
73+
from je_auto_control.utils.file_process.create_project_structure import create_template_dir

je_auto_control/utils/executor/action_executor.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"mouse_left": click_mouse,
3333
"mouse_right": click_mouse,
3434
"mouse_middle": click_mouse,
35+
"click_mouse": click_mouse,
3536
"mouse_table": mouse_table,
3637
"position": position,
3738
"press_mouse": press_mouse,
@@ -70,21 +71,16 @@ def execute_action(action_list: list):
7071
for action in action_list:
7172
event = event_dict.get(action[0])
7273
if len(action) == 2:
73-
param = action[1]
7474
event(**action[1])
7575
elif len(action) == 1:
76-
param = None
7776
event()
7877
else:
7978
raise AutoControlActionException(cant_execute_action_error)
80-
try:
81-
temp_string = "execute: " + str(action)
82-
print(temp_string)
83-
record_total(action[0], param)
84-
execute_record_string = "".join([execute_record_string, temp_string + "\n"])
85-
except AutoControlActionException as error:
86-
record_total(action[0], param, repr(error))
79+
temp_string = "execute: " + str(action)
80+
print(temp_string)
81+
execute_record_string = "".join([execute_record_string, temp_string + "\n"])
8782
except Exception as error:
83+
record_total("execute_action", action_list, repr(error))
8884
print(repr(error), file=sys.stderr)
8985
return execute_record_string
9086

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from pathlib import Path
2+
3+
4+
def create_dir(dir_name: str):
5+
Path(dir_name).mkdir(
6+
parents=True,
7+
exist_ok=True
8+
)
9+
10+
11+
def create_template_dir():
12+
create_dir("auto_control/template")

je_auto_control/wrapper/auto_control_keyboard.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,22 @@ def press_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = F
3636
keyboard.press_key(keycode)
3737
elif sys.platform in ["darwin"]:
3838
keyboard.press_key(keycode, is_shift=is_shift)
39-
if not skip_record:
39+
if skip_record is False:
4040
record_total("press_key", param)
4141
return str(keycode)
4242
except AutoControlKeyboardException as error:
43+
if skip_record is False:
44+
record_total("press_key", param, repr(error))
4345
raise AutoControlKeyboardException(keyboard_press_key + " " + repr(error))
4446
except TypeError as error:
47+
if skip_record is False:
48+
record_total("press_key", param, repr(error))
4549
raise AutoControlKeyboardException(repr(error))
4650
except Exception as error:
47-
if not skip_record:
51+
if skip_record is False:
4852
record_total("press_key", param, repr(error))
53+
else:
54+
raise AutoControlKeyboardException(repr(error))
4955
print(repr(error), file=sys.stderr)
5056

5157

@@ -68,16 +74,22 @@ def release_key(keycode: [int, str], is_shift: bool = False, skip_record: bool =
6874
keyboard.release_key(keycode)
6975
elif sys.platform in ["darwin"]:
7076
keyboard.release_key(keycode, is_shift=is_shift)
71-
if not skip_record:
77+
if skip_record is False:
7278
record_total("release_key", param)
7379
return str(keycode)
7480
except AutoControlKeyboardException as error:
81+
if skip_record is False:
82+
record_total("release_key", param, repr(error))
7583
raise AutoControlKeyboardException(keyboard_release_key + " " + repr(error))
7684
except TypeError as error:
85+
if skip_record is False:
86+
record_total("release_key", param, repr(error))
7787
raise AutoControlKeyboardException(repr(error))
7888
except Exception as error:
79-
if not skip_record:
89+
if skip_record is False:
8090
record_total("release_key", param, repr(error))
91+
else:
92+
raise AutoControlKeyboardException(repr(error))
8193
print(repr(error), file=sys.stderr)
8294

8395

@@ -93,15 +105,19 @@ def type_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = Fa
93105
try:
94106
press_key(keycode, is_shift, skip_record=True)
95107
release_key(keycode, is_shift, skip_record=True)
96-
if not skip_record:
108+
if skip_record is False:
97109
record_total("type_key", param)
98110
return str(keycode)
99111
except AutoControlKeyboardException as error:
112+
if skip_record is False:
113+
record_total("type_key", param, repr(error))
100114
raise AutoControlKeyboardException(keyboard_type_key + " " + repr(error))
101115
except TypeError as error:
116+
if skip_record is False:
117+
record_total("type_key", param, repr(error))
102118
raise AutoControlKeyboardException(repr(error))
103119
except Exception as error:
104-
if not skip_record:
120+
if skip_record is False:
105121
record_total("type_key", param, repr(error))
106122
print(repr(error), file=sys.stderr)
107123

@@ -146,7 +162,7 @@ def write(write_string: str, is_shift: bool = False):
146162
)
147163
else:
148164
raise AutoControlKeyboardException(keyboard_write_cant_find)
149-
except AutoControlKeyboardException:
165+
except AutoControlKeyboardException as error:
150166
print(keyboard_write_cant_find, single_string, sep="\t", file=sys.stderr)
151167
raise AutoControlKeyboardException(keyboard_write_cant_find)
152168
record_total("write", param)

0 commit comments

Comments
 (0)