Add GST Operator Agent EXE v1.6.0 with Windows path-safe build

This commit is contained in:
A R R R Associates
2026-09-20 17:21:20 +05:30
parent c63fc2773c
commit 1462a823ee
9 changed files with 361 additions and 54 deletions
@@ -147,9 +147,11 @@ router = APIRouter(prefix="/tools/accounting/gst-reconciliation", tags=["account
_TOKEN_PURPOSE = "gst_lightweight_operator_v3"
_TOKEN_MINUTES = 15
_UPLOAD_ROOT = Path(tempfile.gettempdir()) / "audit_firm_gst_operator_uploads"
_OPERATOR_AGENT_VERSION = "1.5.1"
_OPERATOR_AGENT_VERSION = "1.6.0"
_OPERATOR_RUNTIME_ROOT = Path(__file__).resolve().parent / "gst_operator_agent_runtime"
_OPERATOR_PACKAGE_FILES = ("gst_operator_agent.py", "requirements.txt", "README.txt", "install_gst_operator_agent.ps1", "uninstall_gst_operator_agent.ps1")
_OPERATOR_PACKAGE_FILES = ("gst_operator_agent.py", "requirements.txt", "README.txt", "install_gst_operator_agent.ps1", "uninstall_gst_operator_agent.ps1", "build_gst_operator_agent_exe.ps1")
_OPERATOR_EXE_NAME = f"ARRR_GST_Operator_Agent_Setup_{_OPERATOR_AGENT_VERSION}.exe"
_OPERATOR_EXE_PATH = _OPERATOR_RUNTIME_ROOT / "dist" / _OPERATOR_EXE_NAME
def _fy_bounds(fy: str) -> tuple[date, date]:
@@ -434,6 +436,35 @@ def page(request: Request, client_id: str = "", registration_id: str = "", perio
@router.get("/operator-agent/download")
def download_operator_agent(request: Request):
db = CommonSessionLocal()
try:
user, response = _require_partner(request, db, "accounting.learning.view")
if response:
return response
if _OPERATOR_EXE_PATH.is_file():
return FileResponse(
path=str(_OPERATOR_EXE_PATH),
media_type="application/vnd.microsoft.portable-executable",
filename=_OPERATOR_EXE_NAME,
)
return JSONResponse(
{
"ok": False,
"error": (
"The GST Operator Agent Windows EXE has not been built in this deployment. "
"Run app/modules/accounting/gst_operator_agent_runtime/build_gst_operator_agent_exe.ps1 "
"on the Windows development repository, commit the generated dist EXE, and redeploy."
),
},
status_code=503,
)
finally:
db.close()
@router.get("/operator-agent/download-source")
def download_operator_agent_source(request: Request):
"""Preserve the existing source/PowerShell package as a repair fallback."""
db = CommonSessionLocal()
try:
user, response = _require_partner(request, db, "accounting.learning.view")
@@ -449,7 +480,7 @@ def download_operator_agent(request: Request):
return JSONResponse({"ok": False, "error": f"GST Operator Agent package file is missing: {name}"}, status_code=500)
archive.write(path, Path("ARRR_GST_Operator_Agent") / name)
memory.seek(0)
headers = {"Content-Disposition": f'attachment; filename="ARRR_GST_Operator_Agent_{_OPERATOR_AGENT_VERSION}.zip"'}
headers = {"Content-Disposition": f'attachment; filename="ARRR_GST_Operator_Agent_Source_{_OPERATOR_AGENT_VERSION}.zip"'}
return StreamingResponse(memory, media_type="application/zip", headers=headers)
finally:
db.close()