From 0a408baa87f2ee31f99c3ca4d4667f994f67f3fb Mon Sep 17 00:00:00 2001 From: Midorica Date: Thu, 23 May 2024 09:21:08 -0400 Subject: [PATCH] DIVA: Fixed binary handler & render_POST errors --- changelog.md | 4 ++++ titles/diva/index.py | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 42c7cfe..a427f2f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,10 @@ # Changelog Documenting updates to ARTEMiS, to be updated every time the master branch is pushed to. +## 20240523 +### DIVA ++ Fixed binary handler & render_POST errors + ## 20240408 ### System + Modified the game specific documentation diff --git a/titles/diva/index.py b/titles/diva/index.py index f414ab2..01e5eeb 100644 --- a/titles/diva/index.py +++ b/titles/diva/index.py @@ -79,7 +79,7 @@ class DivaServlet(BaseServlet): return True - async def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes: + async def render_POST(self, request: Request) -> bytes: req_raw = await request.body() url_header = request.headers @@ -98,8 +98,17 @@ class DivaServlet(BaseServlet): self.logger.info(f"Binary {bin_req_data['cmd']} Request") self.logger.debug(bin_req_data) - handler = getattr(self.base, f"handle_{bin_req_data['cmd']}_request") - resp = handler(bin_req_data) + try: + handler = getattr(self.base, f"handle_{bin_req_data['cmd']}_request") + resp = handler(bin_req_data) + + except AttributeError as e: + self.logger.warning(f"Unhandled {bin_req_data['cmd']} request {e}") + return PlainTextResponse(f"cmd={bin_req_data['cmd']}&req_id={bin_req_data['req_id']}&stat=ok") + + except Exception as e: + self.logger.error(f"Error handling method {e}") + return PlainTextResponse(f"cmd={bin_req_data['cmd']}&req_id={bin_req_data['req_id']}&stat=ok") self.logger.debug( f"Response cmd={bin_req_data['cmd']}&req_id={bin_req_data['req_id']}&stat=ok{resp}"