Skip to content

Commit df20f9f

Browse files
authored
Merge pull request #116 from Integration-Automation/dev
Dev
2 parents d382607 + b8fc8ce commit df20f9f

File tree

5 files changed

+50
-13
lines changed

5 files changed

+50
-13
lines changed

.idea/workspace.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stable.toml renamed to dev.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Rename to build stable version
2-
# This is stable version
1+
# Rename to build dev version
2+
# This is dev version
33
[build-system]
4-
requires = ["setuptools>=61.0"]
4+
requires = ["setuptools"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
8-
name = "je_auto_control"
9-
version = "0.0.149"
8+
name = "je_auto_control_dev"
9+
version = "0.0.90"
1010
authors = [
1111
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
1212
]
@@ -16,7 +16,6 @@ license = { text = "MIT" }
1616
dependencies = [
1717
"je_open_cv",
1818
"pillow",
19-
"numpy",
2019
"APScheduler",
2120
"pyobjc-core;platform_system=='Darwin'",
2221
"pyobjc;platform_system=='Darwin'",

je_auto_control/utils/executor/action_executor.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import builtins
22
import types
33
from inspect import getmembers, isbuiltin
4-
from typing import Any, Dict, List
4+
from typing import Any, Dict, List, Union
55

66
from je_auto_control.utils.exception.exception_tags import action_is_null_error, add_command_exception, \
77
executor_list_error
@@ -18,6 +18,7 @@
1818
from je_auto_control.utils.logging.loggin_instance import auto_control_logger
1919
from je_auto_control.utils.package_manager.package_manager_class import package_manager
2020
from je_auto_control.utils.project.create_project_structure import create_project_dir
21+
from je_auto_control.utils.scheduler.extend_apscheduler import scheduler_manager
2122
from je_auto_control.utils.shell_process.shell_exec import ShellManager
2223
from je_auto_control.utils.start_exe.start_another_process import start_exe
2324
from je_auto_control.utils.test_record.record_test_class import record_action_to_list, test_record_instance
@@ -89,6 +90,15 @@ def __init__(self):
8990
"shell_command": ShellManager().exec_shell,
9091
# Another process
9192
"execute_process": start_exe,
93+
# Scheduler
94+
"scheduler_event_trigger": self.scheduler_event_trigger,
95+
"remove_blocking_scheduler_job": scheduler_manager.remove_blocking_job,
96+
"remove_nonblocking_scheduler_job": scheduler_manager.remove_nonblocking_job,
97+
"start_blocking_scheduler": scheduler_manager.start_block_scheduler,
98+
"start_nonblocking_scheduler": scheduler_manager.start_nonblocking_scheduler,
99+
"start_all_scheduler": scheduler_manager.start_all_scheduler,
100+
"shutdown_blocking_scheduler": scheduler_manager.shutdown_blocking_scheduler,
101+
"shutdown_nonblocking_scheduler": scheduler_manager.shutdown_nonblocking_scheduler,
92102
}
93103
# get all builtin function and add to event dict
94104
for function in getmembers(builtins, isbuiltin):
@@ -156,6 +166,16 @@ def execute_files(self, execute_files_list: list) -> List[Dict[str, str]]:
156166
execute_detail_list.append(self.execute_action(read_action_json(file)))
157167
return execute_detail_list
158168

169+
def scheduler_event_trigger(
170+
self, function: str, id: str = None, args: Union[list, tuple] = None,
171+
kwargs: dict = None, scheduler_type: str = "nonblocking", wait_type: str = "secondly",
172+
wait_value: int = 1, **trigger_args: Any) -> None:
173+
if scheduler_type == "nonblocking":
174+
scheduler_event = scheduler_manager.nonblocking_scheduler_event_dict.get(wait_type)
175+
else:
176+
scheduler_event = scheduler_manager.blocking_scheduler_event_dict.get(wait_type)
177+
scheduler_event(self.event_dict.get(function), id, args, kwargs, wait_value, **trigger_args)
178+
159179

160180
executor = Executor()
161181
package_manager.executor = executor

je_auto_control/utils/scheduler/extend_apscheduler.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ class SchedulerManager(object):
1212
def __init__(self):
1313
self._blocking_schedulers: BlockingScheduler = BlockingScheduler()
1414
self._background_schedulers: BackgroundScheduler = BackgroundScheduler()
15+
self.blocking_scheduler_event_dict = {
16+
"secondly": self.add_interval_blocking_secondly,
17+
"minutely": self.add_interval_blocking_minutely,
18+
"hourly": self.add_interval_blocking_hourly,
19+
"daily": self.add_interval_blocking_daily,
20+
"weekly": self.add_interval_blocking_weekly,
21+
}
22+
self.nonblocking_scheduler_event_dict = {
23+
"secondly": self.add_interval_nonblocking_secondly,
24+
"minutely": self.add_interval_nonblocking_minutely,
25+
"hourly": self.add_interval_nonblocking_hourly,
26+
"daily": self.add_interval_nonblocking_daily,
27+
"weekly": self.add_interval_nonblocking_weekly,
28+
}
1529

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

197211
def shutdown_nonblocking_scheduler(self, wait: bool = False) -> None:
198212
self._background_schedulers.shutdown(wait=wait)
213+
214+
215+
scheduler_manager = SchedulerManager()

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Rename to build dev version
2-
# This is dev version
1+
# Rename to build stable version
2+
# This is stable version
33
[build-system]
4-
requires = ["setuptools"]
4+
requires = ["setuptools>=61.0"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
8-
name = "je_auto_control_dev"
9-
version = "0.0.87"
8+
name = "je_auto_control"
9+
version = "0.0.150"
1010
authors = [
1111
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
1212
]

0 commit comments

Comments
 (0)