Start running the script with enhanced validation. Args: script_path: Path to the script file to run
(self, script_path: str)
| 73 | return self._state == ScriptState.RUNNING |
| 74 | |
| 75 | async def start(self, script_path: str): |
| 76 | """Start running the script with enhanced validation. |
| 77 | |
| 78 | Args: |
| 79 | script_path: Path to the script file to run |
| 80 | """ |
| 81 | script_file = Path(script_path) |
| 82 | if not script_file.exists(): |
| 83 | error_msg = f"Script file not found: {script_path}" |
| 84 | logger.error(f"[ScriptRunner] {error_msg}") |
| 85 | await self._send_error(error_msg) |
| 86 | return |
| 87 | |
| 88 | logger.info(f"[ScriptRunner] Starting execution: {script_path}") |
| 89 | with self._lock: |
| 90 | self.script_path = script_path |
| 91 | self._state = ScriptState.RUNNING |
| 92 | self._run_count = 0 |
| 93 | |
| 94 | if reactivity_explicitly_disabled(): |
| 95 | self._service.disable_reactivity() |
| 96 | else: |
| 97 | logger.info("[ScriptRunner] Reactivity is disabled by configuration") |
| 98 | |
| 99 | try: |
| 100 | await self.run_script() |
| 101 | except Exception as e: |
| 102 | await self._send_error(f"Failed to start script: {e!s}") |
| 103 | self._state = ScriptState.ERROR |
| 104 | |
| 105 | async def stop(self): |
| 106 | """Stop the script and clean up resources.""" |
no test coverage detected