Skip to content

Commit

Permalink
Merge pull request #44 from JE-Chen/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JE-Chen authored Jun 28, 2022
2 parents 846a6b0 + cdf138e commit 50f4165
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .idea/Python_JEAutoControl.iml

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

33 changes: 17 additions & 16 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.25",
version="0.0.26",
author="JE-Chen",
author_email="zenmailman@gmail.com",
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 @@ -57,6 +57,7 @@
from je_auto_control.utils.executor.action_executor import execute_action
from je_auto_control.utils.executor.action_executor import execute_files
from je_auto_control.utils.executor.action_executor import executor
from je_auto_control.utils.executor.action_executor import add_command_to_executor

# timeout
from je_auto_control.utils.timeout.multiprocess_timeout import multiprocess_timeout
Expand Down
2 changes: 2 additions & 0 deletions je_auto_control/utils/exception/exception_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@
timeout_need_on_main_error = "should put timeout function on main"
# HTML
html_generate_no_data_tag = "record is None"
# add command
add_command_exception_tag = "command value type should be as method or function"
6 changes: 5 additions & 1 deletion je_auto_control/utils/exception/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ class AutoControlTimeoutException(AutoControlException):

# html exception

class HTMLException(AutoControlException):
class AutoControlHTMLException(AutoControlException):
pass


class AutoControlAddCommandException(AutoControlException):
pass


41 changes: 17 additions & 24 deletions je_auto_control/utils/executor/action_executor.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
import sys
import types

from je_auto_control import AutoControlActionNullException
from je_auto_control import check_key_is_press
from je_auto_control import click_mouse
from je_auto_control import hotkey
from je_auto_control import keys_table
from je_auto_control import locate_all_image
from je_auto_control import locate_and_click
from je_auto_control import locate_image_center
from je_auto_control import mouse_table
from je_auto_control import position
from je_auto_control import press_key
from je_auto_control import press_mouse
from je_auto_control import release_key
from je_auto_control import release_mouse
from je_auto_control import screenshot
from je_auto_control import scroll
from je_auto_control import keys_table, press_key, release_key, hotkey, type_key, write
from je_auto_control import locate_all_image, locate_and_click, locate_image_center
from je_auto_control import mouse_table, check_key_is_press, position, press_mouse, release_mouse, click_mouse, scroll
from je_auto_control import set_position
from je_auto_control import size
from je_auto_control import special_table
from je_auto_control import type_key
from je_auto_control import write
from je_auto_control.utils.exception.exception_tag import action_is_null_error
from je_auto_control import screenshot, size, special_table
from je_auto_control.utils.exception.exception_tag import action_is_null_error, add_command_exception_tag
from je_auto_control.utils.exception.exception_tag import cant_execute_action_error
from je_auto_control.utils.exception.exceptions import AutoControlActionException
from je_auto_control.utils.exception.exceptions import AutoControlActionException, AutoControlAddCommandException
from je_auto_control.utils.exception.exceptions import AutoControlActionNullException
from je_auto_control.utils.html_report.html_report_generate import generate_html
from je_auto_control.utils.json.json_file import read_action_json
from je_auto_control.utils.test_record.record_test_class import record_action_to_list
from je_auto_control.utils.test_record.record_test_class import test_record_instance
from je_auto_control.utils.test_record.record_test_class import record_action_to_list, test_record_instance


class Executor(object):
Expand Down Expand Up @@ -113,6 +98,14 @@ def execute_files(self, execute_files_list: list) -> list:
executor = Executor()


def add_command_to_executor(command_dict: dict):
for command_name, command in command_dict.items():
if isinstance(command, (types.MethodType, types.FunctionType)):
executor.event_dict.update({command_name: command})
else:
raise AutoControlAddCommandException(add_command_exception_tag)


def execute_action(action_list: list) -> str:
return executor.execute_action(action_list)

Expand Down
4 changes: 2 additions & 2 deletions je_auto_control/utils/html_report/html_report_generate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys

from je_auto_control.utils.test_record.record_test_class import test_record_instance
from je_auto_control.utils.exception.exceptions import HTMLException
from je_auto_control.utils.exception.exceptions import AutoControlHTMLException
from je_auto_control.utils.exception.exception_tag import html_generate_no_data_tag
from threading import Lock

Expand Down Expand Up @@ -135,7 +135,7 @@ def generate_html(html_name: str = "default_name") -> str:
:return: html_string
"""
if len(test_record_instance.test_record_list) == 0:
raise HTMLException(html_generate_no_data_tag)
raise AutoControlHTMLException(html_generate_no_data_tag)
else:
event_str = ""
for record_data in test_record_instance.test_record_list:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="je_auto_control",
version="0.0.92",
version="0.0.93",
author="JE-Chen",
author_email="zenmailman@gmail.com",
description="auto testing",
Expand Down

0 comments on commit 50f4165

Please sign in to comment.