Skip to content
Merged

Dev #30

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="je_auto_control_dev",
version="0.0.16",
version="0.0.17",
author="JE-Chen",
author_email="[email protected]",
description="auto testing",
Expand Down
1 change: 1 addition & 0 deletions je_auto_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@

# file process
from je_auto_control.utils.file_process.get_dir_file_list import get_dir_files_as_list
from je_auto_control.utils.file_process.create_project_structure import create_template_dir
14 changes: 5 additions & 9 deletions je_auto_control/utils/executor/action_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"mouse_left": click_mouse,
"mouse_right": click_mouse,
"mouse_middle": click_mouse,
"click_mouse": click_mouse,
"mouse_table": mouse_table,
"position": position,
"press_mouse": press_mouse,
Expand Down Expand Up @@ -70,21 +71,16 @@ def execute_action(action_list: list):
for action in action_list:
event = event_dict.get(action[0])
if len(action) == 2:
param = action[1]
event(**action[1])
elif len(action) == 1:
param = None
event()
else:
raise AutoControlActionException(cant_execute_action_error)
try:
temp_string = "execute: " + str(action)
print(temp_string)
record_total(action[0], param)
execute_record_string = "".join([execute_record_string, temp_string + "\n"])
except AutoControlActionException as error:
record_total(action[0], param, repr(error))
temp_string = "execute: " + str(action)
print(temp_string)
execute_record_string = "".join([execute_record_string, temp_string + "\n"])
except Exception as error:
record_total("execute_action", action_list, repr(error))
print(repr(error), file=sys.stderr)
return execute_record_string

Expand Down
12 changes: 12 additions & 0 deletions je_auto_control/utils/file_process/create_project_structure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pathlib import Path


def create_dir(dir_name: str):
Path(dir_name).mkdir(
parents=True,
exist_ok=True
)


def create_template_dir():
create_dir("auto_control/template")
30 changes: 23 additions & 7 deletions je_auto_control/wrapper/auto_control_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,22 @@ def press_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = F
keyboard.press_key(keycode)
elif sys.platform in ["darwin"]:
keyboard.press_key(keycode, is_shift=is_shift)
if not skip_record:
if skip_record is False:
record_total("press_key", param)
return str(keycode)
except AutoControlKeyboardException as error:
if skip_record is False:
record_total("press_key", param, repr(error))
raise AutoControlKeyboardException(keyboard_press_key + " " + repr(error))
except TypeError as error:
if skip_record is False:
record_total("press_key", param, repr(error))
raise AutoControlKeyboardException(repr(error))
except Exception as error:
if not skip_record:
if skip_record is False:
record_total("press_key", param, repr(error))
else:
raise AutoControlKeyboardException(repr(error))
print(repr(error), file=sys.stderr)


Expand All @@ -68,16 +74,22 @@ def release_key(keycode: [int, str], is_shift: bool = False, skip_record: bool =
keyboard.release_key(keycode)
elif sys.platform in ["darwin"]:
keyboard.release_key(keycode, is_shift=is_shift)
if not skip_record:
if skip_record is False:
record_total("release_key", param)
return str(keycode)
except AutoControlKeyboardException as error:
if skip_record is False:
record_total("release_key", param, repr(error))
raise AutoControlKeyboardException(keyboard_release_key + " " + repr(error))
except TypeError as error:
if skip_record is False:
record_total("release_key", param, repr(error))
raise AutoControlKeyboardException(repr(error))
except Exception as error:
if not skip_record:
if skip_record is False:
record_total("release_key", param, repr(error))
else:
raise AutoControlKeyboardException(repr(error))
print(repr(error), file=sys.stderr)


Expand All @@ -93,15 +105,19 @@ def type_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = Fa
try:
press_key(keycode, is_shift, skip_record=True)
release_key(keycode, is_shift, skip_record=True)
if not skip_record:
if skip_record is False:
record_total("type_key", param)
return str(keycode)
except AutoControlKeyboardException as error:
if skip_record is False:
record_total("type_key", param, repr(error))
raise AutoControlKeyboardException(keyboard_type_key + " " + repr(error))
except TypeError as error:
if skip_record is False:
record_total("type_key", param, repr(error))
raise AutoControlKeyboardException(repr(error))
except Exception as error:
if not skip_record:
if skip_record is False:
record_total("type_key", param, repr(error))
print(repr(error), file=sys.stderr)

Expand Down Expand Up @@ -146,7 +162,7 @@ def write(write_string: str, is_shift: bool = False):
)
else:
raise AutoControlKeyboardException(keyboard_write_cant_find)
except AutoControlKeyboardException:
except AutoControlKeyboardException as error:
print(keyboard_write_cant_find, single_string, sep="\t", file=sys.stderr)
raise AutoControlKeyboardException(keyboard_write_cant_find)
record_total("write", param)
Expand Down
Loading