Skip to content

Commit

Permalink
Merge pull request #116 from Integration-Automation/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JE-Chen authored Jul 17, 2023
2 parents d382607 + b8fc8ce commit df20f9f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .idea/workspace.xml

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

11 changes: 5 additions & 6 deletions stable.toml → dev.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Rename to build stable version
# This is stable version
# Rename to build dev version
# This is dev version
[build-system]
requires = ["setuptools>=61.0"]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "je_auto_control"
version = "0.0.149"
name = "je_auto_control_dev"
version = "0.0.90"
authors = [
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
]
Expand All @@ -16,7 +16,6 @@ license = { text = "MIT" }
dependencies = [
"je_open_cv",
"pillow",
"numpy",
"APScheduler",
"pyobjc-core;platform_system=='Darwin'",
"pyobjc;platform_system=='Darwin'",
Expand Down
22 changes: 21 additions & 1 deletion 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 types
from inspect import getmembers, isbuiltin
from typing import Any, Dict, List
from typing import Any, Dict, List, Union

from je_auto_control.utils.exception.exception_tags import action_is_null_error, add_command_exception, \
executor_list_error
Expand All @@ -18,6 +18,7 @@
from je_auto_control.utils.logging.loggin_instance import auto_control_logger
from je_auto_control.utils.package_manager.package_manager_class import package_manager
from je_auto_control.utils.project.create_project_structure import create_project_dir
from je_auto_control.utils.scheduler.extend_apscheduler import scheduler_manager
from je_auto_control.utils.shell_process.shell_exec import ShellManager
from je_auto_control.utils.start_exe.start_another_process import start_exe
from je_auto_control.utils.test_record.record_test_class import record_action_to_list, test_record_instance
Expand Down Expand Up @@ -89,6 +90,15 @@ def __init__(self):
"shell_command": ShellManager().exec_shell,
# Another process
"execute_process": start_exe,
# Scheduler
"scheduler_event_trigger": self.scheduler_event_trigger,
"remove_blocking_scheduler_job": scheduler_manager.remove_blocking_job,
"remove_nonblocking_scheduler_job": scheduler_manager.remove_nonblocking_job,
"start_blocking_scheduler": scheduler_manager.start_block_scheduler,
"start_nonblocking_scheduler": scheduler_manager.start_nonblocking_scheduler,
"start_all_scheduler": scheduler_manager.start_all_scheduler,
"shutdown_blocking_scheduler": scheduler_manager.shutdown_blocking_scheduler,
"shutdown_nonblocking_scheduler": scheduler_manager.shutdown_nonblocking_scheduler,
}
# get all builtin function and add to event dict
for function in getmembers(builtins, isbuiltin):
Expand Down Expand Up @@ -156,6 +166,16 @@ def execute_files(self, execute_files_list: list) -> List[Dict[str, str]]:
execute_detail_list.append(self.execute_action(read_action_json(file)))
return execute_detail_list

def scheduler_event_trigger(
self, function: str, id: str = None, args: Union[list, tuple] = None,
kwargs: dict = None, scheduler_type: str = "nonblocking", wait_type: str = "secondly",
wait_value: int = 1, **trigger_args: Any) -> None:
if scheduler_type == "nonblocking":
scheduler_event = scheduler_manager.nonblocking_scheduler_event_dict.get(wait_type)
else:
scheduler_event = scheduler_manager.blocking_scheduler_event_dict.get(wait_type)
scheduler_event(self.event_dict.get(function), id, args, kwargs, wait_value, **trigger_args)


executor = Executor()
package_manager.executor = executor
Expand Down
17 changes: 17 additions & 0 deletions je_auto_control/utils/scheduler/extend_apscheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ class SchedulerManager(object):
def __init__(self):
self._blocking_schedulers: BlockingScheduler = BlockingScheduler()
self._background_schedulers: BackgroundScheduler = BackgroundScheduler()
self.blocking_scheduler_event_dict = {
"secondly": self.add_interval_blocking_secondly,
"minutely": self.add_interval_blocking_minutely,
"hourly": self.add_interval_blocking_hourly,
"daily": self.add_interval_blocking_daily,
"weekly": self.add_interval_blocking_weekly,
}
self.nonblocking_scheduler_event_dict = {
"secondly": self.add_interval_nonblocking_secondly,
"minutely": self.add_interval_nonblocking_minutely,
"hourly": self.add_interval_nonblocking_hourly,
"daily": self.add_interval_nonblocking_daily,
"weekly": self.add_interval_nonblocking_weekly,
}

def add_blocking_job(
self, func: Callable, trigger: str = None, args: Union[list, tuple] = None,
Expand Down Expand Up @@ -196,3 +210,6 @@ def shutdown_blocking_scheduler(self, wait: bool = False) -> None:

def shutdown_nonblocking_scheduler(self, wait: bool = False) -> None:
self._background_schedulers.shutdown(wait=wait)


scheduler_manager = SchedulerManager()
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Rename to build dev version
# This is dev version
# Rename to build stable version
# This is stable version
[build-system]
requires = ["setuptools"]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "je_auto_control_dev"
version = "0.0.87"
name = "je_auto_control"
version = "0.0.150"
authors = [
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
]
Expand Down

0 comments on commit df20f9f

Please sign in to comment.