From 215ad2c6c6cdc967b42776c910365e277ebaee80 Mon Sep 17 00:00:00 2001 From: A R R R Associates Date: Sat, 22 Aug 2026 19:36:51 +0530 Subject: [PATCH] Fix Local Agent 1.13.1 Windows dashboard startup --- app/modules/documents/agent_package.py | 2 +- .../local_agent_runtime/ERPAgentDashboard.pyw | 37 ++++++++++++++++++- .../Open ERP Local Agent Dashboard.vbs | 6 +-- .../erp_local_agent/__init__.py | 3 +- .../local_agent_runtime/open_dashboard.bat | 2 +- 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/app/modules/documents/agent_package.py b/app/modules/documents/agent_package.py index 8bd6260..200aa82 100644 --- a/app/modules/documents/agent_package.py +++ b/app/modules/documents/agent_package.py @@ -4,7 +4,7 @@ import io from pathlib import Path import zipfile -ERP_LOCAL_AGENT_VERSION = "1.13.0" +ERP_LOCAL_AGENT_VERSION = "1.13.1" ERP_LOCAL_AGENT_NAME = "ERP Local Agent" RUNTIME_ROOT = Path(__file__).resolve().parent / "local_agent_runtime" _DETERMINISTIC_ZIP_TIMESTAMP = (2026, 1, 1, 0, 0, 0) diff --git a/app/modules/documents/local_agent_runtime/ERPAgentDashboard.pyw b/app/modules/documents/local_agent_runtime/ERPAgentDashboard.pyw index 3b79c8f..b6fdf86 100644 --- a/app/modules/documents/local_agent_runtime/ERPAgentDashboard.pyw +++ b/app/modules/documents/local_agent_runtime/ERPAgentDashboard.pyw @@ -35,13 +35,48 @@ def _popup(title: str, message: str, error: bool = False) -> None: def _pid_alive(pid: int) -> bool: if pid <= 0: return False + + if os.name == "nt": + try: + import ctypes + + PROCESS_QUERY_LIMITED_INFORMATION = 0x1000 + STILL_ACTIVE = 259 + + kernel32 = ctypes.windll.kernel32 + + handle = kernel32.OpenProcess( + PROCESS_QUERY_LIMITED_INFORMATION, + False, + int(pid), + ) + + if not handle: + return False + + try: + exit_code = ctypes.c_ulong() + + if not kernel32.GetExitCodeProcess( + handle, + ctypes.byref(exit_code), + ): + return False + + return exit_code.value == STILL_ACTIVE + + finally: + kernel32.CloseHandle(handle) + + except Exception: + return False + try: os.kill(pid, 0) return True except OSError: return False - def _supervisor_running() -> bool: try: if not SUPERVISOR_LOCK.exists(): diff --git a/app/modules/documents/local_agent_runtime/Open ERP Local Agent Dashboard.vbs b/app/modules/documents/local_agent_runtime/Open ERP Local Agent Dashboard.vbs index 743ddde..bd65f3f 100644 --- a/app/modules/documents/local_agent_runtime/Open ERP Local Agent Dashboard.vbs +++ b/app/modules/documents/local_agent_runtime/Open ERP Local Agent Dashboard.vbs @@ -1,4 +1,4 @@ -Option Explicit +Option Explicit Dim fso, shell, baseDir, launcher, pyw, py, cmd Set fso = CreateObject("Scripting.FileSystemObject") @@ -15,9 +15,9 @@ If Not fso.FileExists(launcher) Then End If If fso.FileExists(pyw) Then - cmd = """" & pyw & """ """ & launcher & """" + cmd = Chr(34) & pyw & Chr(34) & " " & Chr(34) & launcher & Chr(34) ElseIf fso.FileExists(py) Then - cmd = """" & py & """ """ & launcher & """" + cmd = Chr(34) & py & Chr(34) & " " & Chr(34) & launcher & Chr(34) Else MsgBox "ERP Local Agent Python environment was not found.", 16, "ERP Local Agent" WScript.Quit diff --git a/app/modules/documents/local_agent_runtime/erp_local_agent/__init__.py b/app/modules/documents/local_agent_runtime/erp_local_agent/__init__.py index 9a34ccc..0f0c4ce 100644 --- a/app/modules/documents/local_agent_runtime/erp_local_agent/__init__.py +++ b/app/modules/documents/local_agent_runtime/erp_local_agent/__init__.py @@ -1 +1,2 @@ -__version__ = "1.13.0" +__version__ = "1.13.1" +AGENT_NAME = "ERP Local Agent" diff --git a/app/modules/documents/local_agent_runtime/open_dashboard.bat b/app/modules/documents/local_agent_runtime/open_dashboard.bat index 72fecf7..26419dd 100644 --- a/app/modules/documents/local_agent_runtime/open_dashboard.bat +++ b/app/modules/documents/local_agent_runtime/open_dashboard.bat @@ -1,3 +1,3 @@ -@echo off +@echo off cd /d "%~dp0" wscript.exe "%~dp0Open ERP Local Agent Dashboard.vbs"