Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #31

Merged
merged 3 commits into from
Apr 20, 2022
Merged

Dev #31

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
16 changes: 12 additions & 4 deletions .idea/workspace.xml

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

27 changes: 23 additions & 4 deletions je_auto_control/__main__.py
Original file line number Diff line number Diff line change
@@ -2,13 +2,32 @@
import argparse

from je_auto_control.utils.json.json_file import read_action_json
from je_auto_control.utils.file_process.get_dir_file_list import get_dir_files_as_list
from je_auto_control.utils.executor.action_executor import execute_action
from je_auto_control.utils.executor.action_executor import execute_files


def preprocess_execute_action(file_path: str):
execute_action(read_action_json(file_path))


def preprocess_execute_files(file_path: str):
execute_files(get_dir_files_as_list(file_path))


argparse_event_dict = {
"execute_file": preprocess_execute_action,
"execute_dir": preprocess_execute_files
}

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--execute_file", type=str, help="choose action file to execute")
parser.add_argument("-d", "--execute_dir", type=str, help="choose dir include action file to execute")
args = parser.parse_args()
if args.execute_file is not None:
execute_action(read_action_json(args.execute_file))
else:
print("No argument, Hello There :)")
args = vars(args)
print(args)
for key, value in args.items():
if value is not None:
argparse_event_dict.get(key)(value)

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

setuptools.setup(
name="je_auto_control",
version="0.0.87",
version="0.0.88",
author="JE-Chen",
author_email="zenmailman@gmail.com",
description="auto testing",
5 changes: 2 additions & 3 deletions test/unit_test/argparse/argparse_test.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,5 @@
print(os.getcwd())

os.system("cd " + os.getcwd())
os.system("python je_auto_control --execute_file " + os.getcwd() + r"/test/unit_test/argparse/test.json")


os.system("python je_auto_control --execute_file " + os.getcwd() + r"/test/unit_test/argparse/test1.json")
os.system("python je_auto_control --execute_dir " + os.getcwd() + r"/test/unit_test/argparse")
File renamed without changes.
1 change: 1 addition & 0 deletions test/unit_test/argparse/test2.json
Original file line number Diff line number Diff line change
@@ -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}]]
4 changes: 2 additions & 2 deletions test/unit_test/json/json_test.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,6 @@
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
]

write_action_json(os.getcwd() + "/test.json", test_list)
read_json = read_action_json(os.getcwd() + "/test.json")
write_action_json(os.getcwd() + "/test1.json", test_list)
read_json = read_action_json(os.getcwd() + "/test1.json")
print(read_json)