|
1 | 1 | import builtins |
2 | 2 | import types |
3 | 3 | from inspect import getmembers, isbuiltin |
4 | | -from typing import Any, Dict, List |
| 4 | +from typing import Any, Dict, List, Union |
5 | 5 |
|
6 | 6 | from je_auto_control.utils.exception.exception_tags import action_is_null_error, add_command_exception, \ |
7 | 7 | executor_list_error |
|
18 | 18 | from je_auto_control.utils.logging.loggin_instance import auto_control_logger |
19 | 19 | from je_auto_control.utils.package_manager.package_manager_class import package_manager |
20 | 20 | 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 |
21 | 22 | from je_auto_control.utils.shell_process.shell_exec import ShellManager |
22 | 23 | from je_auto_control.utils.start_exe.start_another_process import start_exe |
23 | 24 | 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): |
89 | 90 | "shell_command": ShellManager().exec_shell, |
90 | 91 | # Another process |
91 | 92 | "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, |
92 | 102 | } |
93 | 103 | # get all builtin function and add to event dict |
94 | 104 | for function in getmembers(builtins, isbuiltin): |
@@ -156,6 +166,16 @@ def execute_files(self, execute_files_list: list) -> List[Dict[str, str]]: |
156 | 166 | execute_detail_list.append(self.execute_action(read_action_json(file))) |
157 | 167 | return execute_detail_list |
158 | 168 |
|
| 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 | + |
159 | 179 |
|
160 | 180 | executor = Executor() |
161 | 181 | package_manager.executor = executor |
|
0 commit comments