Skip to content

Commit

Permalink
Merge pull request #113 from Integration-Automation/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JE-Chen committed Jun 19, 2023
2 parents 960d870 + e6c3906 commit 9a65f3c
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .idea/workspace.xml

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

2 changes: 0 additions & 2 deletions je_auto_control/linux_with_x11/core/utils/x11_linux_vk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from je_auto_control.utils.exception.exception_tags import linux_import_error
from je_auto_control.utils.exception.exceptions import AutoControlException
from je_auto_control.utils.logging.loggin_instance import auto_control_logger

if sys.platform not in ["linux", "linux2"]:
raise AutoControlException(linux_import_error)
Expand Down Expand Up @@ -195,4 +194,3 @@
x11_linux_key_8 = display.keysym_to_keycode(XK.string_to_keysym("8"))
x11_linux_key_9 = display.keysym_to_keycode(XK.string_to_keysym("9"))
x11_linux_key_0 = display.keysym_to_keycode(XK.string_to_keysym("0"))

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from je_auto_control.utils.exception.exception_tags import linux_import_error
from je_auto_control.utils.exception.exceptions import AutoControlException
from je_auto_control.utils.logging.loggin_instance import auto_control_logger

if sys.platform not in ["linux", "linux2"]:
raise AutoControlException(linux_import_error)
Expand All @@ -29,4 +28,3 @@ def release_key(keycode: int) -> None:
time.sleep(0.01)
fake_input(display, X.KeyRelease, keycode)
display.sync()

7 changes: 3 additions & 4 deletions je_auto_control/utils/callback/callback_function_executor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import typing
from typing import Callable, Any
from sys import stderr

from je_auto_control.utils.exception.exception_tags import get_bad_trigger_method, get_bad_trigger_function
Expand Down Expand Up @@ -122,11 +122,11 @@ def __init__(self):
def callback_function(
self,
trigger_function_name: str,
callback_function: typing.Callable,
callback_function: Callable,
callback_function_param: [dict, None] = None,
callback_param_method: str = "kwargs",
**kwargs
) -> typing.Any:
) -> Any:
"""
:param trigger_function_name: what function we want to trigger only accept function in event_dict
:param callback_function: what function we want to callback
Expand Down Expand Up @@ -155,4 +155,3 @@ def callback_function(

callback_executor = CallbackFunctionExecutor()
package_manager.callback_executor = callback_executor

14 changes: 7 additions & 7 deletions je_auto_control/utils/executor/action_executor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import builtins
import sys
import types
from inspect import getmembers, isbuiltin
from typing import Any, Dict, List

from je_auto_control.utils.exception.exception_tags import action_is_null_error, add_command_exception, \
executor_list_error
Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(self):
for function in getmembers(builtins, isbuiltin):
self.event_dict.update({str(function[0]): function[1]})

def _execute_event(self, action: list):
def _execute_event(self, action: list) -> Any:
event = self.event_dict.get(action[0])
if len(action) == 2:
if isinstance(action[1], dict):
Expand All @@ -106,7 +106,7 @@ def _execute_event(self, action: list):
else:
raise AutoControlActionException(cant_execute_action_error + " " + str(action))

def execute_action(self, action_list: [list, dict]) -> dict:
def execute_action(self, action_list: [list, dict]) -> Dict[str, str]:
"""
use to execute all action on action list(action file or program list)
:param action_list the list include action
Expand Down Expand Up @@ -145,7 +145,7 @@ def execute_action(self, action_list: [list, dict]) -> dict:
print(value, flush=True)
return execute_record_dict

def execute_files(self, execute_files_list: list) -> list:
def execute_files(self, execute_files_list: list) -> List[Dict[str, str]]:
"""
:param execute_files_list: list include execute files path
:return: every execute detail as list
Expand All @@ -161,7 +161,7 @@ def execute_files(self, execute_files_list: list) -> list:
package_manager.executor = executor


def add_command_to_executor(command_dict: dict):
def add_command_to_executor(command_dict: dict) -> None:
"""
:param command_dict: dict include command we want to add to event_dict
"""
Expand All @@ -172,9 +172,9 @@ def add_command_to_executor(command_dict: dict):
raise AutoControlAddCommandException(add_command_exception)


def execute_action(action_list: list) -> dict:
def execute_action(action_list: list) -> Dict[str, str]:
return executor.execute_action(action_list)


def execute_files(execute_files_list: list) -> list:
def execute_files(execute_files_list: list) -> List[Dict[str, str]]:
return executor.execute_files(execute_files_list)
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def generate_html() -> str:
return new_html_string


def generate_html_report(html_name: str = "default_name"):
def generate_html_report(html_name: str = "default_name") -> None:
auto_control_logger.info(f"generate_html_report, html_name: {html_name}")
"""
Output html report file
Expand Down
4 changes: 2 additions & 2 deletions je_auto_control/utils/generate_report/generate_json_report.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import json
import sys
from threading import Lock
from typing import Dict, Tuple

from je_auto_control.utils.exception.exception_tags import cant_generate_json_report
from je_auto_control.utils.exception.exceptions import AutoControlGenerateJsonReportException
from je_auto_control.utils.logging.loggin_instance import auto_control_logger
from je_auto_control.utils.test_record.record_test_class import test_record_instance


def generate_json():
def generate_json() -> Tuple[Dict[str, Dict[str, str]], Dict[str, Dict[str, str]]]:
auto_control_logger.info("generate_json")
"""
:return: two dict {success_dict}, {failure_dict}
Expand Down
5 changes: 2 additions & 3 deletions je_auto_control/utils/generate_report/generate_xml_report.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import sys
from threading import Lock
from xml.dom.minidom import parseString
from typing import Tuple, Dict, Union

from je_auto_control.utils.generate_report.generate_json_report import generate_json
from je_auto_control.utils.logging.loggin_instance import auto_control_logger
from je_auto_control.utils.xml.change_xml_structure.change_xml_structure import dict_to_elements_tree


def generate_xml():
def generate_xml() -> Tuple[Union[str, bytes], Union[str, bytes]]:
auto_control_logger.info("generate_xml")
"""
:return: two dict {success_dict}, {failure_dict}
Expand Down Expand Up @@ -52,4 +52,3 @@ def generate_xml_report(xml_file_name: str = "default_name"):
f"failed: {repr(error)}")
finally:
lock.release()

3 changes: 2 additions & 1 deletion je_auto_control/utils/json/json_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
from pathlib import Path
from threading import Lock
from typing import List, Dict

from je_auto_control.utils.exception.exception_tags import cant_find_json_error
from je_auto_control.utils.exception.exception_tags import cant_save_json_error
Expand All @@ -9,7 +10,7 @@
_lock = Lock()


def read_action_json(json_file_path: str) -> list:
def read_action_json(json_file_path: str) -> List[List[Dict[str, Dict[str, str]]]]:
"""
use to read action file
:param json_file_path json file's path to read
Expand Down
11 changes: 6 additions & 5 deletions je_auto_control/utils/package_manager/package_manager_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from importlib.util import find_spec
from inspect import getmembers, isfunction, isbuiltin, isclass
from sys import stderr
from typing import Union, Callable, Dict

from je_auto_control.utils.logging.loggin_instance import auto_control_logger

Expand All @@ -14,7 +15,7 @@ def __init__(self):
self.executor = None
self.callback_executor = None

def check_package(self, package: str):
def check_package(self, package: str) -> Union[None, Dict[str, Callable]]:
"""
:param package: package to check exists or not
:return: package if find else None
Expand All @@ -30,7 +31,7 @@ def check_package(self, package: str):
print(repr(error), file=stderr)
return self.installed_package_dict.get(package, None)

def add_package_to_executor(self, package):
def add_package_to_executor(self, package) -> None:
auto_control_logger.info(f"add_package_to_executor, package: {package}")
"""
:param package: package's function will add to executor
Expand All @@ -40,7 +41,7 @@ def add_package_to_executor(self, package):
target=self.executor
)

def add_package_to_callback_executor(self, package):
def add_package_to_callback_executor(self, package) -> None:
auto_control_logger.info(f"add_package_to_callback_executor, package: {package}")
"""
:param package: package's function will add to callback_executor
Expand All @@ -50,7 +51,7 @@ def add_package_to_callback_executor(self, package):
target=self.callback_executor
)

def get_member(self, package, predicate, target):
def get_member(self, package, predicate, target) -> None:
"""
:param package: package we want to get member
:param predicate: predicate
Expand All @@ -67,7 +68,7 @@ def get_member(self, package, predicate, target):
else:
print(f"Executor error {self.executor}", file=stderr)

def add_package_to_target(self, package, target):
def add_package_to_target(self, package, target) -> None:
"""
:param package: package we want to get member
:param target: which event_dict will be added
Expand Down
Loading

0 comments on commit 9a65f3c

Please sign in to comment.